PresentModalViewController 不全屏显示

发布于 2024-11-10 15:34:20 字数 543 浏览 2 评论 0原文

仅横向应用程序。在我的主窗口 xib 上,我有一个 UIView。我正在以编程方式将 UIScrollview 加载到 UIView 中,效果很好。在该滚动视图上,我有一个按钮,可以通过 PresentModalViewController 调用调出“详细信息”屏幕(单独的视图控制器):

    LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self presentModalViewController:learnit animated:YES];    
[learnit release];

正在调用该操作,但当滚动视图打开时,模式视图不会占据整个屏幕。一个子视图。相反,它会弹出到父滚动视图并翻转方向等。这不是所需的行为。

有关如何在调用来自滚动视图(主 xib 上容器 UIView 的子视图)时使模态视图全屏显示的任何指导吗?

Landscape only app. On my main window xib, I've got a UIView. I'm loading a UIScrollview programatically into that UIView which works just fine. On that scrollview, I've got a button that brings up a "detail" screen (a separate view controller), via a presentModalViewController call:

    LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self presentModalViewController:learnit animated:YES];    
[learnit release];

The action's being called but the modal view doesn't take up the whole screen when the scrollview is a subview. Instead, it's popping into the parent scrollview and flipping the orientation, etc. Not the desired behavior.

Any guidance on how to make the modal view full screen when the call is from scrollview which is a subview of a container UIView on the main xib?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

多情出卖 2024-11-17 15:34:20

感谢所有的评论。在某处发现了一个关于重写presentModalViewController并在循环中冒泡直到到达主控制器(在我的例子中为HomeViewController)的提示。像冠军一样工作。

- (void) presentModalViewController:(UIViewController *)screen animated:(BOOL)animated {
    UIResponder *responder = self;
    while (responder && ![responder isKindOfClass:[HomeViewController class]]) {
        responder = [responder nextResponder];
    }
    [(UIViewController *)responder presentModalViewController:screen animated:YES];
}

我在包含进行调用的按钮的 UIScrollview 的 .m 文件中进行重写。

Thanks for all the comments. Found a tip somewhere on overriding presentModalViewController and bubbling up in a loop until the main controller's reached (in my case, HomeViewController). Worked like a champ.

- (void) presentModalViewController:(UIViewController *)screen animated:(BOOL)animated {
    UIResponder *responder = self;
    while (responder && ![responder isKindOfClass:[HomeViewController class]]) {
        responder = [responder nextResponder];
    }
    [(UIViewController *)responder presentModalViewController:screen animated:YES];
}

I'm overriding in the .m file of the UIScrollview that contains the button that makes the call.

心凉怎暖 2024-11-17 15:34:20

尝试添加 subview,而不是 presentModelViewController 作为:

LearnITViewController *tempView = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:[NSBundle mainBundle]];
self.learnITViewController = tempView;
[tempView release];
[self.view addSubview:mainMenuView.view]; 

并添加此

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);//or left
}

Try adding subview, rather than presentModelViewController as:

LearnITViewController *tempView = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:[NSBundle mainBundle]];
self.learnITViewController = tempView;
[tempView release];
[self.view addSubview:mainMenuView.view]; 

And add This too

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);//or left
}
余生一个溪 2024-11-17 15:34:20
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.learnitView setsetWantsFullScreenLayout:YES];

或者

self.learnitView.wantsFullScreenLayout = YES;
[self presentModalViewController:learnit animated:YES];    
[learnit release];
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.learnitView setsetWantsFullScreenLayout:YES];

or

self.learnitView.wantsFullScreenLayout = YES;
[self presentModalViewController:learnit animated:YES];    
[learnit release];
且行且努力 2024-11-17 15:34:20

superview 中添加 UIViewController,而不是 self

LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.view.superview presentModalViewController:learnit animated:YES];    
[learnit release];

Instead of self add UIViewController in superview.

LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.view.superview presentModalViewController:learnit animated:YES];    
[learnit release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文