【问题标题】:UIModalPresentationFormSheet in iPad Landscape Not Centering Properly?iPad景观中的UIModalPresentationFormSheet未正确居中?
【发布时间】:2014-05-07 01:45:59
【问题描述】:

当我使用 UIModalPresentationFormSheet 样式呈现我的模态视图时,它会正确居中,但是当键盘出现时(一秒钟后),它不会将模态视图垂直向上移动,而是将其向左或向右移动,几乎就像如果它认为它处于纵向模式。如果我旋转我的设备,它会自行固定到正确的方向。

该应用设置为仅横向,但我无法解决问题。

这里有什么问题?

我正在使用以下方法显示我的视图:

- (void)presentEventEditViewControllerWithEventStore:(EKEventStore*)eventStore {

EKEventEditViewController *evc = [[EKEventEditViewController alloc] init];
evc.eventStore = eventStore;
EKEvent* event = [EKEvent eventWithEventStore:eventStore];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"MM.dd.yyyy"];
NSString *startDate = @"11.01.2014";
NSString *endDate = @"11.07.2014";

//Pre-populated Info
event.startDate = [dateFormatter dateFromString:startDate];
event.endDate = [dateFormatter dateFromString:endDate];
event.allDay = YES;
event.location = @"The Big Island, Hawaii";
event.availability = EKEventAvailabilityBusy;
evc.event = event;
evc.editViewDelegate = self;
evc.delegate = self;

evc.modalPresentationStyle = UIModalPresentationFormSheet;
evc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentViewController:evc animated:YES completion:nil];

}

【问题讨论】:

  • 嗨托尼。不,我不是,我实际上想要键盘,只是当它成为第一响应者而不是将我的视图向上推时,它将向左或向右推。
  • 当视图成为第一响应者时,您使用什么来“推送”视图?
  • 刚刚更新了我的答案以显示我的方法。
  • 你说得对……EKEventEditViewController 有问题……也许……因为有自己的 navController!!!
  • 此行为仅在 evc.modalPresentationStyle = UIModalPresentationFormSheet;但 modalPresentationStyle = UIModalPresentationPageSheet 没问题!!!

标签: ios ipad uiinterfaceorientation first-responder uimodalpresentationstyle


【解决方案1】:

我在 iOS 7 中遇到了完全相同的问题。我通过这样做解决了它:

[self presentViewController:evc animated:YES completion:^{
    evc.view.superview.center = self.view.center;
}];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    • 2019-05-18
    相关资源
    最近更新 更多