我正在尝试展示一个显示我的服务条款的UIAlertController。我不能简单地将服务条款粘贴到消息体中,这是实现这一目标的最佳方法。我也只是在应用程序首次启动时调用它一次。
func agree(){
let alert = UIAlertController(title: "Terms of Service", message:"", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Agree", style: .default, handler: { (action: UIAlertAction) in
print("OK")
}))
self.present(alert, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
if UserDefaults.standard.bool(forKey: "Walkthrough") {
print("already shown")
// Terms have been accepted, proceed as normal
} else {
agree()
UserDefaults.standard.set(true, forKey: "Walkthrough")
}
}