我尝试从UITableViewCell中调用UIAlertController。
我有我的代理。
我称之为下面我 TableViewCell 类中的内部。
为了呈现视图控制器,我在我的mainView类中设置了DEPFlightStripCellDelegate,并调用我上面声明的函数“callAlert”来显示警报。
然而,代理返回了nil。有人知道为什么吗?
我有我的代理。
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)
}
}
为了呈现视图控制器,我在我的mainView类中设置了DEPFlightStripCellDelegate,并调用我上面声明的函数“callAlert”来显示警报。
class mainView: UIViewController,UITextFieldDelegate, DEPFlightStripCellDelegate {
func callAlert(AlertCon: UIAlertController!) {
println("Test")
self.presentViewController(AlertCon, animated: true, completion: nil)
}
}
然而,代理返回了nil。有人知道为什么吗?