佳为好友

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

创建:2012.03.16
转:http://stackoverflow.com/questions/2457947/how-to-resize-a-uipresentationformsheet
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
+++++

posted on 2012-12-29 11:06 佳为好友 阅读(310) 评论(0)  编辑 收藏 引用 所属分类: UI


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(1)

随笔分类

搜索

最新评论

评论排行榜