iPad 无法加载模态视图

发布于 2024-11-29 16:30:45 字数 1379 浏览 3 评论 0原文

加载模态视图时出现此错误。

*** 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[” setValue:forUndefinedKey:]: 这个类与 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];

I'm getting this error when loading a modal view.

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x72785a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aboutTableView.'

It works perfectly fine from the iPhone, but I'm having this trouble with the iPad.

- (IBAction)showOptionsMenu
{
    self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    self.optionsNavController.modalPresentationStyle = UIModalPresentationFormSheet;
    self.optionsNavController.modalInPopover = YES;
    [self presentModalViewController:self.optionsNavController animated:YES];
}

Update:

This works but the UIButton is not being displayed:

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];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗恋未遂 2024-12-06 16:30:45

这是为两种设备启动模式视图的好方法:

#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];
}

SomeViewController

-(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];
}

Here is a good way to launch a modal view for both devices:

#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];
}

SomeViewController

-(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];
}
梦里南柯 2024-12-06 16:30:45

您是否为 iphone/ipad 使用不同的 xib?

如果是这样,请检查您的 iPad 版本中的连接,可能存在您尚未删除的处理连接。

Are you using different xibs for iphone/ipad?

If so check your connections in your iPad version there is probably a handing connection that you have not removed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文