我正在尝试使用UIModalPresentationFormSheet在iPad上调整UIViewController的大小,虽然我已经在< = iOS 7上工作,但我不能在iOS 8
解决方法
对于iOS 8,您必须设置“preferredContentSize”属性,但对于iOS 7及更早版本,您必须设置superview.frame属性.
示例代码:
UIViewController* modalController = [[UIViewController alloc]init]; modalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; modalController.modalPresentationStyle = UIModalPresentationFormSheet; CGPoint frameSize = CGPointMake([[UIScreen mainScreen] bounds].size.width*0.95f,[[UIScreen mainScreen] bounds].size.height*0.95f); CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; CGFloat screenHeight = screenRect.size.height; // Resizing for iOS 8 modalController.preferredContentSize = CGSizeMake(frameSize.x,frameSize.y); // Resizing for <= iOS 7 modalController.view.superview.frame = CGRectMake((screenWidth - frameSize.x)/2,(screenHeight - frameSize.y)/2,frameSize.x,frameSize.y); UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; [vc presentViewController:modalController animated:YES completion:nil];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。