我使用以下代码将设置页面称为 viewController 上的表单:
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];
}
当设置页面被调用和关闭时,viewDidAppear 和 viewWillAppear 仅在 iPad 上不会在原始页面上调用。在 iPhone 上,由于它不是表单,它可以完美运行,此外,当我将 iPad 上的设置页面作为常规模式视图而不是表单调用时,它们都会被调用。请帮忙。谢谢!