gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:00:29 24 4
gpt4 key购买 nike

首先,我觉得苹果真的不喜欢我们为横向 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com