对于同步屏幕,我在 ios5 上制作了 ModalViewController。我使用了这段代码:
synchViewController = [[SynchViewController alloc] initWithNibName:@"SynchViewController" bundle:nil];
synchViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:synchViewController animated:YES];
synchViewController.view.superview.frame = CGRectMake(0,0,SYNCHVIEW_WIDTH,SYNCHVIEW_HEIGHT);
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGPoint center = CGPointMake(CGRectGetMidX(screenBounds), CGRectGetMidY(screenBounds));
synchViewController.view.superview.center = CGPointMake(center.y, center.x);
控制器是在 xib 文件中设计的。该代码有效。
现在在 ios6 下,presentModalViewController 已贬值。我更改了方法,但现在模态视图控制器完全移位并且大小错误。
我怎样才能拥有像我设计的 xib 布局大小的 iMessage 登录屏幕?
编辑:它适用于此代码:synchViewController = [[SynchViewController alloc] initWithNibName:@"SynchViewController" bundle:nil];
synchViewController.modalPresentationStyle = UIModalPresentationFormSheet;
synchViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:synchViewController animated:YES completion:nil];
synchViewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
synchViewController.view.superview.frame = CGRectMake(0,0,
SYNCHVIEW_WIDTH,// Width
SYNCHVIEW_HEIGHT// Height
);
synchViewController.view.superview.bounds = CGRectMake(0, 0, SYNCHVIEW_WIDTH, SYNCHVIEW_HEIGHT);
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGPoint center = CGPointMake(CGRectGetMidX(screenBounds), CGRectGetMidY(screenBounds));
synchViewController.view.superview.center = CGPointMake(center.y, center.x);
但只有当我将动画设置为 YES 时。当我试图在没有动画的情况下加载它时,它又完全移位了,为什么?