從烏爾視圖控制器u有通過控制器的參考,消息標題諸如
Settings.getAlertViewConroller(self, DialogTitle: "Test Sale", strDialogMessege: "You are performing a test sale. This is not a real transaction.")
其中設置是NSObject.In設置類的子類u必須定義方法
class func getAlertViewConroller(globleAlert:UIViewController,DialogTitle:NSString,strDialogMessege:NSString){
let actionSheetController: UIAlertController = UIAlertController(title: DialogTitle, message: strDialogMessege, preferredStyle: .Alert)
let nextAction: UIAlertAction = UIAlertAction(title: "OK", style: .Default) { action -> Void in
}
actionSheetController.addAction(nextAction)
globleAlert.presentViewController(actionSheetController, animated: true, completion:nil)
}
即呈現UIAlertController。
'presentViewController'是UIViewController'的'的方法,而不是'NSObject' – Krumelur
@Krumelur我知道,但我想從我的班級顯示一個UIAlertController。有沒有其他解決方法? – Nicholas