【发布时间】:2015-08-09 13:50:38
【问题描述】:
我正在尝试向自定义UITableViewCell 添加警报以呈现UIAlertView 我需要从UIViewController 调用presentViewController。但是,我不知道如何从 UITableViewCell 类访问当前的 UIViewController 实例。下面的代码是我尝试通过扩展来做到这一点。
我收到这个错误
表达式解析为未使用的函数。
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 {
【问题讨论】:
标签: ios uitableview swift uiviewcontroller