【发布时间】:2015-04-09 14:56:37
【问题描述】:
我尝试从 UITableViewCell 中调用 UIAlertController。
我有我的代表
protocol DEPFlightStripCellDelegate {
func callAlert(AlertCon: UIAlertController!)
}
我在下面的 TableViewCell 类中调用了它。
class DEPFlightStripCell: UITableViewCell {
var delegate: DEPFlightStripCellDelegate?
@IBAction func changeClearedFlightLevel(sender: UIButton) {
let AddAlert: UIAlertController = UIAlertController(title: "Select Altitude", message: "", preferredStyle: .Alert)
self.delegate?.callAlert(AddAlert)
}
}
为了呈现视图控制器,我使用 DEPFlightStripCellDelegate 在我的 mainView 类中设置它,并调用我在“callAlert”上方声明的函数来显示警报。
class mainView: UIViewController,UITextFieldDelegate, DEPFlightStripCellDelegate {
func callAlert(AlertCon: UIAlertController!) {
println("Test")
self.presentViewController(AlertCon, animated: true, completion: nil)
}
}
但是,委托返回 nil。有人知道为什么吗?
【问题讨论】:
标签: ios uitableview ipad swift uialertcontroller