我开发了 iPad 应用程序。屏幕中有一个表格视图。如果用户单击任何单元格,那么我会打开弹出框。我遇到这样的错误非常罕见
Fatal Exception NSInvalidArgumentException
-[UIPopoverController _commonPresentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.
使用以下方法;
UIViewController *contentViewController = [[UIViewController alloc] init];
[contentViewController.view setFrame:CGRectMake(0, 0, 320, 460)];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:contentViewController] autorelease];
self.popOver=[[UIPopoverController alloc] initWithContentViewController:navController];
self.popOver.delegate = self;
CGRect rectInTableView = [self.menuItems rectForRowAtIndexPath:tableRowID];
CGRect rectInSuperview = [self.menuItems convertRect:rectInTableView toView:self.view];
rectInSuperview.size.width=320;
[self.popOver presentPopoverFromRect:rectInSuperview inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
[contentViewController release];