加载模态视图时出现此错误。
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x72785a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aboutTableView.'
它完全可以在iPhone上运行,但我在iPad上遇到了这个麻烦。
- (IBAction)showOptionsMenu
{
self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.optionsNavController.modalPresentationStyle = UIModalPresentationFormSheet;
self.optionsNavController.modalInPopover = YES;
[self presentModalViewController:self.optionsNavController animated:YES];
}
更新
这样可行但是UIButton没有显示:
MoreViewController *svc = [[[MoreViewController alloc] init] autorelease];
optionsNavController= [[UINavigationController alloc] initWithRootViewController:svc];
self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.optionsNavController.modalPresentationStyle = UIModalPresentationFormSheet;
self.optionsNavController.modalInPopover = YES;
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(dissmissView)];
self.optionsNavController.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
[self presentModalViewController:self.optionsNavController animated:YES];
答案 0 :(得分:0)
您是否在iphone / ipad上使用不同的xib?
如果是这样,请检查您的iPad版本中的连接,可能是您尚未删除的处理连接。
答案 1 :(得分:0)
这是为两个设备启动模态视图的好方法:
#define IDIOM UI_USER_INTERFACE_IDIOM()
#define IPAD UIUserInterfaceIdiomPad
SomeViewController *svc = [[[SomeViewController alloc] init] autorelease];
if ( IDIOM == IPAD ) {
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:svc];
[controller setModalPresentationStyle:UIModalPresentationFormSheet];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:controller animated:YES];
[controller release];
} else {
/* or you can present the view as modal: */
[self.navigationController pushViewController:svc animated:YES];
}
-(void)viewDidLoad
{
[super viewDidLoad];
if ( IDIOM == IPAD ) {
UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self action:@selector(dismiss)] autorelease];
self.navigationItem.leftBarButtonItem = doneButton;
}
}
-(void)dismiss
{
[self dismissModalViewControllerAnimated:YES];
}