开发者

Problem with UIPopOverController shrinking in width when navigationController pushes a new view(screenshots included)

开发者 https://www.devze.com 2023-03-02 04:41 出处:网络
Ok I have a view that we will call homeView. When a certain button is pushed on homeView, a UIPopOverController is presented in the following way:

Ok I have a view that we will call homeView. When a certain button is pushed on homeView, a UIPopOverController is presented in the following way:

self.studyPicker = [[[StudyPickerController alloc] initWithStudyArray:self.studyArray ViewNum:butto.tag] autorelease];

    UINavigationController *navController = [[UINavigationController alloc]  initWithRootViewController:self.studyPicker];

    _studyPicker.delegate = self;
    self.studyPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];               

    [self.studyPickerPopover presentPopoverFromRect:CGRectMake(955,60, 22,10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Which works great. I get a nice big popover controller that displays my tableView data just the way I need it. Just as an FYI, in my StudyPickerController viewDidLoad method, I am also setting this:

    self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);

Which allows me to make the size of my tableView nice and big. The probl开发者_开发知识库em I am experiencing is after I select a row in this first tableView. The navigationController pushes the new view just fine, but then the width of my popover controller gets cut in half! It doesn't make any sense! I have tried everything and can't figure out what is going on. In the new view, called ScreenView, it also has the same code in viewDidLoad:

    self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);

An interesting observation that I've made but don't know what to do with is that if I take out the contentForSize code from the Second view in the tableView, or the one that I am trying to push to within the controller, when it pushes, it gets cut in half again, to the width of a standard popover controller you see in like Safari. But adding that code in makes it 2 times as wide, like there are two glued together or something, but it is still more narrow than the original width.

I don't know what's going on here, hopefully someone can help me out!

Thanks

Here is an image of the width it should stay:

Problem with UIPopOverController shrinking in width when navigationController pushes a new view(screenshots included)

And then here it is after it pushes the new view:

Problem with UIPopOverController shrinking in width when navigationController pushes a new view(screenshots included)


For each view you are presenting in the UIPopoverController, set the property contentSizeForViewInPopover

For example:

myViewController.contentSizeForViewInPopover = CGSize(120.0f, 320.0f);

You will need to account for the size of the UINavigationBar (that you get from the UINavigationBar) inside the UIPopoverController but overall that controls the stretching and contracting of the UIPopoverController.

0

精彩评论

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