zoukankan      html  css  js  c++  java
  • 关于 presentViewController 时机

      
      类似微信、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
  • 相关阅读:
    JQuery hover鼠标变换
    装饰者模式
    principle04
    Method Injection
    观察者模式
    Java SPI
    Redis--学习01
    OO设计中5大原则
    knowledge
    策略模式
  • 原文地址:https://www.cnblogs.com/10-19-92/p/5710515.html
Copyright © 2011-2022 走看看