ios: push viewcontroller 时出现Presenting view controllers on detached view controllers is discouraged

释放双眼,带上耳机,听听看~!

原因

a,b,c 三个viewcontroller,a作为根视图,b.view 添加到a上,在b中模态(presentViewController)弹出c.

这种情况就会出现标题的警告

解决方法:

//如下
[self.view.window.rootViewControllerpresentViewController:controller animated:YEScompletion:nil];

/*这里一段解释

 The reason of this warning is i was presenting a view controller over a small view that is not full size view. Given below is the image of my project. where on click on four option above. User navigate to different childviewcontroller's view.(it works like tabViewcontroller). But the childviewcontroller contains view of small size. So if we present a view from childviewcontroller it gives this warning.
*/

本人也觉得这是个治标不治本的方法,这个方法表面上好像解决了问题,实际可能在特殊情况下引发更严重的bug

  • 2.正确使用viewcontroller,此问题是误用viewcontroller引起的

 

人已赞赏
iOS文章

iOS开发-关闭/收起键盘方法总结

2020-5-12 23:46:48

iOS文章

iOS开发CUICatalog: Invalid asset name supplied:

2020-5-13 1:02:02

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索