首先,我觉得苹果真的不喜欢我们为横向视图优化应用程序。
在与我的应用程序苦苦挣扎 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];
}