Presenting view controllers on detached view controllers is discouraged

来源:互联网 发布:java 读取zip包中文件 编辑:程序博客网 时间:2024/05/16 21:38

代码present一个viewController时,出现该警告,并造成代码执行出现问题。

present的代码如下:

    if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0) {        [self presentModalViewController:picker animated:NO];            }else{        [self presentViewController:picker animated:NO completion:nil];    }

代码在iOS及以上运行,按理应该不会出错。


根据搜索结果,得出解决方法,将以上代码改成如下即可:

    if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0) {        [self.view.window.rootViewController presentModalViewController:picker animated:NO];            }else{        [self.view.window.rootViewController presentViewController:picker animated:NO completion:nil];    }

项目仓促,有时间再来研究下原因吧。



0 0
原创粉丝点击