Quantcast
Channel: C++博客-所有随笔
Viewing all articles
Browse latest Browse all 7881

转:修改UIModalPresentationFormSheet风格的model view controller的宽高

$
0
0
创建:2012.03.16
You are able to adjust the frame of a modal view after presenting it:
MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
targetController
.modalPresentationStyle = UIModalPresentationFormSheet;
targetController
.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter
[self presentModalViewController:targetController animated:YES];
targetController
.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
targetController
.view.superview.center = self.view.center;//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
It works also for me on iPad, but... If I rotate the device, the view is not centered – Mauro Delrio Aug 25 '11 at 17:56
@MauroDelrio To make it work correctly from landscape you need to flip the center coordinates. ex:
 CGPoint center = self.view.center; targetController.view.superview.center = {isPortrait} ? center : CGPointMake(center.y, center.x);
 – Nate Weiner Jan 6 at 1:36
+++++


佳为好友 2012-12-29 11:06 发表评论

Viewing all articles
Browse latest Browse all 7881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>