类似微信、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

相关文章:

  • 2022-12-23
  • 2022-01-11
  • 2021-11-02
  • 2022-03-04
  • 2021-09-01
  • 2017-12-10
  • 2022-02-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2019-07-10
  • 2022-02-21
相关资源
相似解决方案