iPad版中的UIModalPresentationFormSheet无法正确居中?

时间:2014-05-07 01:45:59

标签: ios ipad uiinterfaceorientation first-responder uimodalpresentationstyle

当我使用UIModalPresentationFormSheet样式呈现我的模态视图时,它正确居中,但是当键盘出现时(后面的第二个),而不是垂直向上移动模态视图,它将向左或向右移动,几乎如如果它认为它是在纵向模式。如果我旋转设备,它会将自己固定到正确的方向。

应用程序仅设置为横向,但我无法弄清楚问题。

这里有什么问题?

enter image description here

enter image description here

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

- (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];

}

1 个答案:

答案 0 :(得分:0)

我在iOS 7中遇到了完全相同的问题。我通过以下方式解决了这个问题:

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