当 navigationController 推送新视图时,UIPopOverController 宽度缩小的问题(包括屏幕截图)
好的,我有一个视图,我们将其称为 homeView。当在 homeView 上按下某个按钮时,UIPopOverController 会以以下方式呈现:
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];
效果很好。我得到了一个漂亮的大弹出控制器,它可以按照我需要的方式显示我的 tableView 数据。仅供参考,在我的 StudyPickerController viewDidLoad 方法中,我还设置了这个:
self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);
这允许我使 tableView 的大小变得又大又好。 我遇到的问题是在我在第一个 tableView 中选择一行之后。 navigationController 很好地推送了新视图,但随后我的弹出窗口控制器的宽度被削减了一半!这没有任何意义!我已经尝试了一切,但无法弄清楚发生了什么。在名为 ScreenView 的新视图中,它在 viewDidLoad 中也有相同的代码:
self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);
一个有趣的观察,我做了但不知道该怎么办,如果我取出 contentForSize 代码从 tableView 中的 Second 视图,或者我试图在控制器中推送的视图,当它推送时,它会再次切成两半,达到您看到的标准弹出窗口控制器的宽度就像Safari一样。但是添加该代码会使其宽度增加两倍,就像有两个粘在一起或其他什么一样,但它仍然比原始宽度更窄。
我不知道这是怎么回事,希望有人能帮助我!
谢谢
这是它应该保留的宽度的图像:
然后这是推送新视图后的情况:
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 problem 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:
And then here it is after it pushes the new view:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您在
UIPopoverController
中呈现的每个视图,设置属性contentSizeForViewInPopover
例如:
myViewController.contentSizeForViewInPopover = CGSize(120.0f, 320.0f);
您需要考虑
UINavigationBar
的大小(您从UIPopoverController
内的UINavigationBar
获得的,但总体上控制着拉伸和收缩UIPopoverController
的。For each view you are presenting in the
UIPopoverController
, set the propertycontentSizeForViewInPopover
For example:
myViewController.contentSizeForViewInPopover = CGSize(120.0f, 320.0f);
You will need to account for the size of the
UINavigationBar
(that you get from theUINavigationBar
) inside theUIPopoverController
but overall that controls the stretching and contracting of theUIPopoverController
.