小编Cal*_*han的帖子

来自其他swift.file的swift3调用alert函数

我是swift3的新手.现在,我正在寻找一种从其他swift.file调用alert函数的方法

像这样:

//MainView.swift
//Call function
AlertFun.ShowAlert(title: "Title", message: "message..." )

//Another page for storing functions
//Function.swift

public class AlertFun {
    class func ShowAlert(title: String, message: String ) {    
        let alert = UIAlertController(title: tile, message: message, preferredStyle: UIAlertControllerStyle.alert)
        alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

问题在这里......不能这样做......

    self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我该如何实现它?谢谢.

ios swift3

2
推荐指数
1
解决办法
2919
查看次数

标签 统计

ios ×1

swift3 ×1