Ipad 从模态视图控制器显示Popover
我正在尝试从UIModalPresentationPageSheet中的按钮演示Popover。它会使应用程序崩溃,并向控制台返回以下消息:Ipad 从模态视图控制器显示Popover,ipad,modal-dialog,uipopovercontroller,Ipad,Modal Dialog,Uipopovercontroller,我正在尝试从UIModalPresentationPageSheet中的按钮演示Popover。它会使应用程序崩溃,并向控制台返回以下消息: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a view which does not have a window.' 我的代码在标准视图控制器中运行良好。正如消息所暗示
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a view which does not have a window.'
我的代码在标准视图控制器中运行良好。正如消息所暗示的,模态中有一些东西阻止了它的显示。我在这个话题上做了大量的搜索,但没有找到解决方案。我不得不相信这是可能的,因为我在1Password等应用程序中看到了非常类似的东西
非常感谢您的指点和/或建议。以下代码似乎适合我,请尝试以下操作:
[_pPopOverController presentPopoverFromRect:CGRectMake(0, 0, 768, 900) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
我不知道您使用的是哪个SDK,但5.1没有任何例外。我正在显示一个文本字段中的popover,下面的代码起作用:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[_popController presentPopoverFromRect:textField.frame
inView:textField.superview
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
return NO;
}我敢打赌,问题在于您传递的是视图控制器,而不是inView参数的视图。它正在尝试获取UIViewController的.window,而UIViewController没有,UIViews有