Change pop-over contentsize using navigationcontroller

限于喜欢 提交于 2019-12-10 18:32:57

问题


I want to show a popover with a custom contentsize. I can do it doing like so

UINavigationController* popoverContent = [[UINavigationController alloc] init];


    UIView* popoverView = [[UIView alloc]  initWithFrame:CGRectMake(0, 0, 800, 800)];

    popoverView.backgroundColor = [UIColor blueColor];

    popoverContent.view = popoverView;

    popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);
    UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
    [pop presentPopoverFromRect:CGRectMake(80.0, 210.0, 160.0, 40.0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];

but if I change the content to :

popoverContent.viewControllers = [NSArray arrayWithObject:myViewController];

the

popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);

the size doesn't change at all.

How can I change the content size while using the navigation controller? Thanks


回答1:


Explicitly changing the popovers size works:

 [self.popoverController setPopoverContentSize:myView.size animated:YES];

But I agree that contentSizeForViewInPopover should work. It doesn't for me anyway.



来源:https://stackoverflow.com/questions/3459834/change-pop-over-contentsize-using-navigationcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!