How to reload data on a subview if the model is presented using UIModalPresentationFormSheet

477 views Asked by At

I have implemented a UIModalPresentationFormSheet in my iPad application. The new view partially covers the sub view and allows the user to make a choice. This all works great, however...

When the user selects an option I would like to update the underlying view with the new details, but cannot get it to work!

I have tried using setNeedsDisplay or [table reloadData]; in both the viewDidAppear and viewWillAppear methods.

Some code for codes sake:

- (void)viewWillAppear:(BOOL)animated {
    [self updateUserDetails];
    [self.myTableView reloadData];
}

- (void)viewDidAppear:(BOOL)animated {
    [self updateUserDetails];   
    [self.myTableView reloadData];
}

- (void)updateUserDetails {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:selection forKey:@"userDetail"];
}

My transition is as follows. If this line is commented out then the application functions as expected:

myNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;

Any help appreciated, thanks!

2

There are 2 answers

0
jyce1492 On

I think you should put the reloading of data near the code where you detect the selection of the user, not in the viewWillAppear of viewDidAppear.

2
decazuk On

You can set self.view.autolayoutSubviews = NO; UI will change your view's size for UIModalPresentationFormSheet. This may be break the reload process.