您需要保存在UserDefaults用户选择
下面的代码是用斯威夫特3
如果你不希望加载entryViewController然后在AppDelegate中:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//retrieve values from UserDefaults
//for the first time it will be false, because it was not set earlier
let isAccepted = UserDefaults.standard.bool(forKey: "isAccepted")
if isAccepted == false {
//present your disclaimer here
}else{
//show entryViewController
}
return true
}
也可以加载entryViewController和现在的免责声明瞬间,然后在您的entryViewController:
override func viewDidLoad() {
super.viewDidLoad()
//retrieve values from UserDefaults
//for the first time it will be false, because it was not set earlier
let isAccepted = UserDefaults.standard.bool(forKey: "isAccepted")
if isAccepted == false {
//present your disclaimer here
}
}
在DisclaimerVC:
@IBAction func accept(_ sender: UIButton){
//it can be another action in your controller
//but anyway, you should save user choice after that
UserDefaults.standard.set(true, forKey: "isAccepted")
//add code here to dismiss disclaimer
}
这已经被问过很多次。请在提问前进行搜索。这里是一个示例解决方案:https://github.com/mattneub/RegistrationExample – matt
你介意解释为什么这被标记为重复?您的答案和iOS项目都不支持免责声明。 –
狮子狗和西班牙狗都是狗。你需要制造一只狗;这只是一个偶然的事实,它是什么品种。正如我所说过的,一次性显示视图控制器(或直到用户满足某些要求)的问题在这里已经得到了很大的处理。 – matt