显示键盘后,窗体不在iOS7中居中

时间:2013-11-20 14:49:17

标签: ios7 keyboard

我的应用程序在iOS 5和6中运行良好。但是在iOS 7中,在显示键盘后,模态窗体不会居中。应用程序中的另一个表单不会发生这种情况,但我没有看到它们之间的区别。正如您在下面的图像中看到的那样,在第一张图像中它居中,在显示键盘后它移动到左侧。任何的想法?谢谢你的帮助。

更新: 我使用popover来显示它:

-(IBAction) doSignUp:(id)sender{
    StayInformedVC *vc = [handler getStayInformedVC:self]; //[[StayInformedVC alloc] init];
    popoverStayInformed = [[UIPopoverController alloc]initWithContentViewController:vc];     
    popoverStayInformed.popoverBackgroundViewClass = [BorderlessPopoverBackgroundView class]; 
    popoverStayInformed.delegate = self; 
    vc.delegate = self;

    float width, height; 

    width = vc.contentSizeForViewInPopover.width;
    height = vc.contentSizeForViewInPopover.height; 
    CGRect frame = CGRectMake(self.view.bounds.size.width/2 - width/2 , self.view.bounds.size.height/2, 1,1);

    [popoverStayInformed presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    // adds a dim to the background 
    if ( dimViewStayInformed == nil ) {
        dimViewStayInformed = [[UIView alloc] initWithFrame:self.view.bounds]; 
        [dimViewStayInformed setBackgroundColor:[UIColor blackColor]]; 
        [dimViewStayInformed setAlpha:0.5f]; 

    }

    [self.view addSubview:dimViewStayInformed]; 

}

在stayInformeddVC.m我有:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.contentSizeForViewInPopover = CGSizeMake(popUpView.bounds.size.width, popUpView.bounds.size.height);
}

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

我刚刚找到解决方案:

我改变了这个: [popoverStayInformed presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

由此:

[popoverStayInformed presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight animated:YES];