iPad的presentModalViewController出现在错误的位置
首先,我感觉苹果真的不喜欢我们优化应用程序的横向视图。
在与我的应用程序斗争了 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];
}
First of, I get the feeling apple really doesnt like us optimizing apps for landscape view.
After struggling with my app for 2 days I finally convince it to always and only show in Landscape mode. I even convinced the UIViewController that I present with presentModalViewController to appear in landscape as well. So far so good...
The position of the UIViewController that I present with UIModalPresentationFormSheet is all the way to the bottom right (with the ipad in Landscape positition). I cannot get it to move to the center like it should. Does anyone have any ideas why and or how this works and how I can make it apear in the right position?
EDIT: Added code, this code is called from a UIViewController when a button is pushed.
- (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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用布局 IB 上的小“自动定位弹簧”?也许您将其固定在底部和右侧,只需删除这些附件即可。
这是给您的链接: http://disanji.net/ iOS_Doc/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html
如果您愿意,也可以在代码中完成。
Have you tried playing with the little "autoposition springs" on the layout IB? Probably you have it attached to the bottom and right, simply remove those attachments.
Here's a link for you: http://disanji.net/iOS_Doc/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html
Can also be done in code if you like.