Ios UIPageViewController中的AlertViewController
我正在构建一个具有以下情节提要的Swift 3应用程序: 左侧(绿色)是一个UIPageViewController,它将2个导航控制器保存为2个页面。这允许用户在应用程序的两个子部分之间滑动 问题如下。我试图以黑色显示警报UIViewController 以下是显示警报的代码:Ios UIPageViewController中的AlertViewController,ios,swift,uipageviewcontroller,uialertcontroller,Ios,Swift,Uipageviewcontroller,Uialertcontroller,我正在构建一个具有以下情节提要的Swift 3应用程序: 左侧(绿色)是一个UIPageViewController,它将2个导航控制器保存为2个页面。这允许用户在应用程序的两个子部分之间滑动 问题如下。我试图以黑色显示警报UIViewController 以下是显示警报的代码: override func viewDidAppear(_ animated: Bool) { let alert = UIAlertController(title: "Hello", m
override func viewDidAppear(_ animated: Bool) {
let alert = UIAlertController(title: "Hello", message: "World", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: { action in
alert.dismiss(animated: true, completion: nil)
}))
self.present(alert, animated: true, completion: nil)
}
它可以工作,但我总是得到以下警告:
不建议在分离的视图控制器上显示视图控制器
我还尝试使用DispatchQueue.main.async
来显示视图,但遇到了相同的警告
然而,我发现,如果我将导航控制器(底部一个)设置为初始视图控制器,它将在没有警告的情况下工作
那么,使用UIPageViewController是否意味着页面将被分离
我错过了什么?我忘记链接了吗?你可以试试下面的内容
[self.view.window.rootViewController presentViewController:alert animated:YES completion:nil];
当你完成后,你可以放弃它
[self dismissViewControllerAnimated:YES completion:nil];
让我知道这是否有效。好,它有效。所以我不能在页面中显示来自控制器的视图?我是否每次都必须使用
rootViewController
?