iOSApp未登录处理

一、弹出登录界面登录
  • 当前控制器遵守 UITabBarControllerDelegate 协议
  • 实现相关协议方法
func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool {
        if islogin {
            return true
        }else{
            // 弹出登录框代码
            
            return false
        }
    }
  • 登录成功后设置selectedIndex跳转
二、把登录界面作为一个tabbar其中一个页面,登录成功后更换程序根控制器
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
QGTabBarController *tabBar = [[QGTabBarController alloc] init];
tabBar.selectedIndex = 1;
delegate.window.rootViewController = tabBar;

你可能感兴趣的:(iOSApp未登录处理)