开发者

How to correctly instantiate a PopoverController

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


}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜