如何正确实例化 PopoverController
我有一个 SplitviewController
,其中包含多个可能的 Detailviews
(Webviews
、Tableviews
、常规 UIViews
)。
例如,我在顶部有一个 NavigationController
,然后浏览一些表格。
最后我展示了一些Content
,比如说一个UIWebview
。我将 iPad 旋转为纵向,并在工具栏中添加一个 Button
,从中显示 popOverController
。
在 Buttonclick
上,我说:
if (!popoverController) {
if (self.view.window != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController: [appDelegateiPad naviPad]];
popoverController.delegate = self;
}
}
在这里,我实例化一个 PopOverController
,而 Content
是 splitview 的左侧部分,从我离开的位置开始。一切都很好。
但是当我旋转时,我收到此警告:
CoreAnimation: ignoring exception: Popovers cannot be presented from a view which does not have a window.
在屏幕上,popOverController 重新出现,内容为空内容(我会说是黑色半透明),但我不知道为什么,因为我忽略了它,并且不能再有另一个实例,因为我只创建了一个实例单击按钮时。
这几天来这让我发疯。
感谢任何(!)帮助!
-(void) showPopOver:(id) sender {
NSLog(@"showing popover?");
if (!popoverController) {
if (self.view.window != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:[appDelegateiPad naviPad]];
//RootViewController *r = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle: nil];
// popoverController = [[UIPopoverController alloc] initWithContentViewController:r];
//popoverController.popoverContentSize = CGSizeMake(320, 800);
//popoverController.delegate = self;
}
}
if (![popoverController isPopoverVisible]) {
[popoverController presentPopoverFromBarButtonItem:barButton3 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//[popoverController presentPopoverFromRect:CGRectMake(10, 10, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
else {
[popoverController dismissPopoverAnimated:NO];
}
}
I have a SplitviewController
with multiple possible Detailviews
(Webviews
, Tableviews
, regular UIViews
).
As an example, I have a NavigationController
on top, then navigate through some tables.
Finally I show some Content
, lets say a UIWebview
. I rotate the iPad to portrait, and in the toolbar I add a Button
from which the popOverController
is displayed.
On Buttonclick
I say:
if (!popoverController) {
if (self.view.window != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController: [appDelegateiPad naviPad]];
popoverController.delegate = self;
}
}
Here, I instantiate a PopOverController
and the Content
is the left part of the splitview, from the point I left off. All is nice.
But when I rotate, I get this warning:
CoreAnimation: ignoring exception: Popovers cannot be presented from a view which does not have a window.
And on the screen the popOverController reappears with empty content (black translucent I would say) but I don't know why, since I dismissed it and there cant be another instance since I only create one on buttonclick.
This has been driving me crazy for days.
ANY(!) help is appreciated!
-(void) showPopOver:(id) sender {
NSLog(@"showing popover?");
if (!popoverController) {
if (self.view.window != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:[appDelegateiPad naviPad]];
//RootViewController *r = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle: nil];
// popoverController = [[UIPopoverController alloc] initWithContentViewController:r];
//popoverController.popoverContentSize = CGSizeMake(320, 800);
//popoverController.delegate = self;
}
}
if (![popoverController isPopoverVisible]) {
[popoverController presentPopoverFromBarButtonItem:barButton3 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//[popoverController presentPopoverFromRect:CGRectMake(10, 10, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
else {
[popoverController dismissPopoverAnimated:NO];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论