【发布时间】:2011-04-27 21:53:32
【问题描述】:
我有一个简单的 IPAD 结构,其中包含来自 viewController 的视图:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ClockVC *clockVC = [[ClockVC alloc]init];
clockVC.view.frame = CGRectMake(100, 100, clockVC.view.bounds.size.width, clockVC.view.bounds.size.height);
[self.window addSubview:clockVC.view];
[self.window makeKeyAndVisible];
return YES;
}
clockVC 有一个由这段代码定义的 viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.autoresizingMask = UIViewAutoresizingNone;
self.view.autoresizesSubviews = UIViewAutoresizingNone;
}
clockVC 的边界由 IB 定义并在应用程序中覆盖:didFinishLaunching... 宽度和高度分别为 200 和 150。
ClockVC 实现了一步自动旋转的方法: /
/ Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[UIView animateWithDuration:0.5
animations:^{self.view.alpha = 0;}
];
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[UIView animateWithDuration:1
animations:^{self.view.alpha = 1;}
];
}
在第一次加载时,页面被正确查看,clockVC 视图就位。 当我旋转clockVC视图(其autoResizeMask设置为UIViewAutoresizingNon)调整大小以占据整个屏幕。
为什么?我想保持初始大小。
这里是我的问题的截图。 旋转前:
旋转后:
【问题讨论】:
-
我刚刚将
clockVC.view.autoresizingMask = UIViewAutoresizingNone;添加到应用程序:didifinishlaunching into app delegate... 但没有任何改变。
标签: objective-c ios ipad autoresizingmask