的AppDelegate:UIAlertView中委託功能不被調用
func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary) {
let aps: NSDictionary = userInfo.objectForKey("aps") as NSDictionary
UpdatesViewController().newArticle(aps)
}
UpdatesViewController:
class UpdatesViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate {
func newArticle(userInfo: NSDictionary) {
let title: NSString = userInfo["alert"] as NSString
UIAlertView(title: "New update", message: title, delegate: self, cancelButtonTitle: "Dismiss", otherButtonTitles: "Read more").show()
}
func alertView(alertView: UIAlertView, willDismissWithButtonIndex buttonIndex: Int) {
println(buttonIndex)
}
func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
println(buttonIndex)
}
}
我接收UIAlertView
與來自APNS正確的消息時發送一個推送通知。問題是當在UIAlertView
中按下兩個按鈕中的任何一個時,記錄不會通過println
記錄。
任何想法?
'UpdatesViewController()'創建UpdatesViewController'的'的新實例。這將在代理被調用之前發佈,因爲它不保留在任何地方。你是否試圖在現有的視圖控制器中調用該函數? – rakeshbs 2015-03-03 11:33:01
更好地說「沒有強有力的參考」。 – zaph 2015-03-03 11:40:28