江边鸟_ 2015-09-01 10:12 采纳率: 25%
浏览 1720
已结题

关于ios开发,UITabBarViewController的状态恢复

重点应该是最后一个方法,那样写UITabBarViewController的恢复请问有没有什么问题,因为模拟器的结果是tabViewController 的子视图控制器是不能恢复的
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];

return YES;

}

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    if(!self.window.rootViewController) {

    BNRHypnosisViewController *hvc = [[BNRHypnosisViewController alloc] init];
    
    NSBundle *appBundle = [NSBundle mainBundle];
    BNRReminderViewController *rvc = [[BNRReminderViewController alloc] initWithNibName: @"BNRReminderViewController" bundle: appBundle];
    
    UITabBarController *tabBarController = [UITabBarController new];
    tabBarController.viewControllers = @[hvc, rvc];
    tabBarController.tabBar.tintColor = [UIColor redColor];
    //设置恢复标识
    tabBarController.restorationIdentifier = NSStringFromClass([tabBarController class]);
    
    self.window.rootViewController = tabBarController;
    

    }

    [self.window makeKeyAndVisible];

    /*[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];*/

    // [application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories: nil]];

    return YES;
    }
    //恢复类
    -(UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
    {
    UIViewController *tabBarController = [[UITabBarController alloc] init];

    tabBarController.restorationIdentifier = NSStringFromClass([tabBarController class]);

    //背景颜色红色,方便调试
    tabBarController.view.backgroundColor = [UIColor redColor];

    self.window.rootViewController = tabBarController;

    return tabBarController;
    }

  • 写回答

1条回答 默认 最新

  • devmiao 2015-09-01 15:01
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题