你好,我有我已经宣布AlertViewFunction这样我如何传递一个控制器的功能
func displayAlertMessage(userMessage: String,//controller){
let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil)
myAlert.addAction(okAction);
self.presentViewController(myAlert, animated: true, completion: nil)
}
的问题是一个工具类,我不能使用self
这里
self.presentViewController(myAlert, animated: true, completion: nil)
我想通过一个控制器到这个功能,所以我可以这样使用
controller.presentViewController(myAlert, animated: true, completion: nil)
如何通过控制器来自任何ViewController。比方说,如果我在LoginViewController
Utility().displayAlertMessage(Message.INTERNETISNOTCONNECTED,//controller)
非常感谢您 – hellosheikh
@hellosheikh我很高兴我能帮助! –