开发者

iPad Won't Load Modal View

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

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewContro开发者_如何学编程ller 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];


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜