开发者

restoring segmenedControl's selected index after application being terminated

so i have this segmented control in the interface i am using user defaults to store the selected segment in applications view controller's applicationDidEnterBackground and restoring it in - (void)applicationWillEnterForeground {

NSNumber *indexNumber;

if (indexNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"selectedIndex"]) {

NSInteger selectedIndex = [indexNumber integerValue]; self.segmentedControl.selectedSegmentIndex = selectedIndex; }

but when im launching the app, selecting a segment and then killing the application, i get this error. Program received sign开发者_Go百科al: “SIGKILL” on relaunch.

any help would be appreciated


Hard to tell without more info, but likely this is caused because the controller and segmented control are not available in applicationWillEnterForeground. (They haven't been instantiated yet.)

You might need more this to the viewDidLoad of the viewController.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜