zoukankan      html  css  js  c++  java
  • 5.多个Storyboard切换

    通知中心 注册通知中心监控用户登录状态

    1.定义一个方法

      -(void)registerNotification{

        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

        //参数说明: 1.通知中心监听者 2.发生通知时调用的选择器方法 3.发生的通知名称 4.传递给选择器方法的对象

        [center addObserver:self selector:@selector(loginStateChange) name:kNotificationUserLogonState object:nil];

      }

      定义一个常量  #define kNotificationUserLogonState @“kNotificationUserLogon”

      -(void)loginStateChange{  //选择器方法

        // 登录成功后执行。。。

        }  

    在登录成功的地方调用方法

      [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationUserLogonState object:nil];

      

    2.在AppDelegate.h中 添加一个属性

    //用是否登录成功  @property (assign, nonatomic)BOOL isUserLogon;

      在身证验证通过方法  用户上线之前 添加 _isUserLogon = YES;

    在到 loginStateChange 方法中判断_isUserLogon进入那个storyboard.

    -(void)loginStateChange{

      UIStoryboard *storyboard = nil;

      if(_isUserLogon){storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];}

      else{storyboard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];}

    //把Storyboard的初始视图控制器设置为window的rootViewController

      [self.window setRootViewController:storyboard.instantiateInitalViewController];

    }

  • 相关阅读:
    JUnit4的使用
    Android中使用JUnit4测试发生fatal error
    计算器的M+是什么意思
    初识Ildasm.exe——IL反编译的实用工具
    jsp下载
    jsp文件上传
    java.sql.SQLException: Io 异常:
    在PowerDesigner中创建物理模型时DBMS选项为空
    oracle10g还原被drop的表
    oracle创建用户
  • 原文地址:https://www.cnblogs.com/qq907374866/p/4253003.html
Copyright © 2011-2022 走看看