2

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

在与我的应用程序苦苦挣扎 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];
}
4

1 回答 1

0

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

这是给你的链接:http: //disanji.net/iOS_Doc/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html

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

于 2011-09-07T15:14:05.257 回答