UINavigationController State Restoration (without Storyboards)

后端 未结 3 819
一个人的身影
一个人的身影 2021-02-04 03:38

I\'ve been toying around with state restoration. In the code below, the scroll position of the UITableViewController gets restored, however, if I were to tap through into the de

3条回答
  •  盖世英雄少女心
    2021-02-04 04:25

    the only problem with your code is navigation controller these two lines

    UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:table];
        navCon.restorationIdentifier = @"navigationController";
    

    i dont know why navigation controller never get its restoration class. i had the same problem. i found some alternative solution to create a navigation controller stand alone in storyboard and use that.

    here is code

    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" 
        bundle:nil];
    UINavigationController* navigationController = [storyboard
        instantiateViewControllerWithIdentifier:
        @"UINavigationController"];
    
    navigationController.viewControllers = @[myController];
    

    it will work fine .

    just follow this http://petr-pavlik.squarespace.com/blog/2013/6/16/stare-restoration-without-storyboard

提交回复
热议问题