【问题标题】:Modal View using UIModalPresentationFormSheet appears offscreen使用 UIModalPresentationFormSheet 的模态视图出现在屏幕外
【发布时间】:2010-11-25 00:17:27
【问题描述】:

我有一个 UIViewController 实现

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

然后,我尝试在该视图顶部弹出一个模式:

ModalViewController *modalViewController = [[ModalViewController alloc] init];
modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[mainViewController presentModalViewController:modalViewController animated:YES]; 

如果我在 ipad 处于纵向时启动模态,它工作正常。但是当我把它放在横向并尝试启动模式时,模式出现在 ipad 右上角的一半屏幕外。有什么想法吗?

【问题讨论】:

    标签: ipad iphone-sdk-3.0 modal-dialog showmodaldialog


    【解决方案1】:

    在 ModalViewController 中,以与 mainViewController 中相同的方式实现 shouldAutorotateToInterfaceOrientation(两者都需要就它们支持的方向达成一致)。

    【讨论】:

    • 当我呈现 UIModalPresentationFormSheet 时视图控制器没有居中怎么办?你知道为什么吗?
    • 对不起,没有。建议您使用代码和其他详细信息提出新问题。
    • 那么我做了什么,实现了相同的 ViewController 但作为 TableView,它在 FormSheet 上扩展,现在居中 √ :)
    猜你喜欢
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 2020-12-11
    • 2011-12-08
    • 1970-01-01
    • 2010-10-29
    • 2017-01-04
    • 1970-01-01
    相关资源
    最近更新 更多