ios - iPad presentModalViewController 出现在错误的位置

标签 ios ipad presentmodalviewcontroller

首先,我觉得苹果真的不喜欢我们为横向 View 优化应用程序。

在与我的应用程序苦苦挣扎 2 天后,我终于说服它始终且仅在横向模式下显示。我什至说服了我与 presentModalViewController 一起呈现的 UIViewController 也出现在横向中。到现在为止还挺好...

我使用 UIModalPresentationFormSheet 呈现的 UIViewController 的位置一直到右下角(ipad 处于横向位置)。我不能让它像它应该的那样移动到中心。有没有人知道为什么和或如何工作,以及如何让它出现在正确的位置?

编辑:添加代码,按下按钮时从 UIViewController 调用此代码。

- (void) buttonPushed
{
    pickerViewController = [[UIViewController alloc] init];
    [pickerViewController.view setBackgroundColor:[UIColor whiteColor]];


    _pickerCustomers = [[UIPickerView alloc] initWithFrame:CGRectMake(22,20,380,216)];
    _pickerCustomers.delegate = self;
    _pickerCustomers.dataSource = self;
    [_pickerCustomers setShowsSelectionIndicator:YES];
    [pickerViewController.view addSubview:_pickerCustomers];

    _btnPickerDone = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [_btnPickerDone setFrame: CGRectMake(300,250,98,45)];
    [_btnPickerDone setTitle:@"Select" forState:UIControlStateNormal];
    [pickerViewController.view addSubview:_btnPickerDone];

    pickerViewController.modalPresentationStyle = UIModalPresentationFormSheet;

    [self presentModalViewController:pickerViewController animated:YES];
}

最佳答案

您是否尝试过使用布局 IB 上的小“自动定位 Spring ”?可能您已将其连接到底部和右侧,只需删除这些附件即可。

这是一个链接:http://disanji.net/iOS_Doc/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html

如果您愿意,也可以在代码中完成。

关于ios - iPad presentModalViewController 出现在错误的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7336184/

相关文章:

iOS 数据存储指南拒绝

objective-c - iOS - 构建失败,CocoaPods 找不到头文件

ios - 关闭当前模态视图 Controller ,然后呈现新的模态视图 Controller

ios - 如何使用当前的 NSPersistentStore 方法在本地和 iCloud 中创建可共享的 Core Data .sqlite 备份

升级到 xcode 4.3.2 后,iOS 模拟器不再连接到网络 midi

ios - 如何在添加 UITabBarController 之前显示导航 Controller (一组 View Controller ),例如登录或注册

iphone - 当我在 View 之间来回切换时,我的viewDidLoad没有被第二次调用?

ios - presentViewController 和显示导航栏

ios - IIViewDeckController 和 presentViewController

ios - swift 和 sprite 工具包在屏幕上拖动手指时画一条直线