Different behaviour in iOS 7 and iOS 8 on -(void)v

2020-05-03 11:27发布

问题:

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    //Reset all NSUserDefaults values
}

My app was previously working fine in iOS 7 but after upgraded to iOS 8, it is no longer working.

This is happening in my parent VC where user is required to select some option in another (child) VC which transit via "Partial Curl". In iOS 8, seems like all my options are not saved in child VC anymore when I transit back to my parent VC.

FYI I store my options selection in child VC inside NSUserDefaults and access them again in parent VC.

回答1:

Upon checking, I realised in iOS 7, the function (void)viewDidAppear:(BOOL)animated only called once during first load. However, in iOS 8, this function is called everytime I transit back from the child VC via "Partial Curl". Therefore whatever options that chosen in child VC got reset when transit back to parent VC.

This is the different between iOS 7 and iOS 8.