类似微信、QQ这些应用如果用户没有登录,会弹出登录界面,如果 presentViewController 是写在 viewDidAppear 之前,会有警告
Presenting view controllers on detached view controllers is discouraged
Unbalanced calls to begin/end appearance transitions for
大致意思是Presenting控制器还没有完全出现就模态出一个视图,产生层级问题。
将presentViewController写在视图已经出现就行 viewDidAppear 里
UIStoryboard 分类
- @implementation UIStoryboard (Extention)
+ (__kindofUIViewController *)wl_instantiateViewControllerWithStoryboardName:(NSString *)storyboardName
identifier:(NSString *)identifier {
NSAssert(storyboardName.length > 0, @"参数 storyboardName 为 nil 或空字符串.");
UIStoryboard *storyboard = [selfstoryboardWithName:storyboardName bundle:nil];
NSAssert(storyboard, @"文件不存在 => %@", [NSString stringWithFormat:@"%@.storyboard", storyboardName]);
if (identifier) {
return [storyboard instantiateViewControllerWithIdentifier:identifier];
}
UIViewController *initialVC = [storyboard instantiateInitialViewController];
NSAssert(initialVC, @"%@ 未指定 initial 控制器.",
[NSString stringWithFormat:@"%@.storyboard", storyboardName]);
return initialVC;
}
@end - 对于 (__kindofUIViewController *) 是返回值可以是 UIViewController 及其子类,毕竟有时候我们需要模态出来的视图需要包装NavigationController