Я пытаюсь добавить оповещения к таможне UITableViewCell
, чтобы представить UIAlertView
Мне нужно позвонить presentViewController с UIViewController
. Тем не менее, я не знаю, как получить доступ к текущему экземпляру UIViewController
из класса UITableViewCell
. Следующий код - это моя попытка сделать это с расширением.Представляя UIAlertController от UITableViewCell
Я получаю эту ошибку
Expression разрешенного к неиспользуемой функции.
extension UIViewController
{
class func alertReminden(timeInterval: Int)
{
var refreshAlert = UIAlertController(title: "Refresh", message: "All data will be lost.", preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
Alarm.createReminder("Catch the Bus",
timeInterval: NSDate(timeIntervalSinceNow: Double(timeInterval * 60)))
}))
refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
println("Handle Cancel Logic here")
}))
UIViewController.presentViewController(refreshAlert)
}
}
class CustomRouteViewCell: UITableViewCell {
wow супер hack гений boy! – mattyU
Спасибо, друзья за ваши удивительные усилия. – Jaydip
Это не сработало, так как мое табличное представление было также в контроллере навигации. Я смог представить, если пусть topController = UIApplication.topViewController() { topController.present (alertController, animated: true, completion: noil) } – DoesData