I am calling a settings page as a form sheet over a viewController using the following code:
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *device = [standardUserDefaults objectForKey:@"Device"];
if ([device isEqualToString:@"iPhone"]) {
Settings_iPhone *screen = [[Settings_iPhone alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];
}
if ([device isEqualToString:@"iPad"]) {
Settings_iPhone *screen = [[Settings_iPhone alloc] initWithNibName:@"Settings_iPad" bundle:nil];
screen.modalPresentationStyle = UIModalPresentationFormSheet;
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];
}
When the settings page is called and dismissed, viewDidAppear and viewWillAppear are not called on the original page only on the iPad. On the iPhone, since its not a formsheet, it works perfectly, and furthermore when I call the settings page on the iPad as a regular modal view instead of a form sheet, they both get called. Please help. Thanks!
You can pass the value of the parent view controller to the modal view before presenting it (just add a property and keep the reference). When you're done in your modal view, call a method on the parent (in this one you can pass whatever that is needed to be passed to the parent view
-(void)imDone:(NSObject yourValue)
and call the dismiss on the Parent (dismissViewController:Animated:
).You can use this approach on both iPhone and iPad.
I hope it helps.