嗨朋友们,
单击工具栏按钮时,会出现我的弹出视图。当我将模拟器旋转到横向时,会显示以下错误消息:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
*** First throw call stack:
(0x1b69052 0x1868d0a 0x1b11a78 0x1b119e9 0x9ae72e 0x9affcb 0x9b26eb 0x281a39 0x1b34885 0x1b347a8 0x1c61aa 0x5490d8 0x54d499 0x54d584 0x11ede00 0x15ff4f0 0x1aa0833 0x1a9fdb4 0x1a9fccb 0x209a879 0x209a93e 0x51ca9b 0x29dd 0x2955)
处理我的按钮事件的代码是:
-(IBAction)name:(id)sender
{
if ([_popover isPopoverVisible])
{
[_popover dismissPopoverAnimated:YES];
}
else {
task * content = [[task alloc] init];
content.navigationItem.title =@"name";
[content setDelegate:self];
navController = [[UINavigationController alloc] initWithRootViewController: content];
_popover = [[UIPopoverController alloc]
initWithContentViewController:navController];
_popover. popoverContentSize=CGSizeMake(350, 480);
[_popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
谢谢..