0
我有一个简单的视图控制器与一些自定义按钮添加到它。视图控制器不旋转
-(void)viewWillLayoutSubviews {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
NSLog(@"Detected IPAD");
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
NSLog(@"Orientation is PORTAIT");
UIImage *serviceTask = [UIImage imageNamed:@"main_l_serviceorder.png"];
btnServiceOrder = [UIButton buttonWithType:UIButtonTypeCustom];
btnServiceOrder.frame = CGRectMake(143.0, 37.0, 226.0, 200.0);
[btnServiceOrder setBackgroundImage:serviceTask forState:UIControlStateNormal];
[btnServiceOrder addTarget:self action:@selector(gotoServiceOrders:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnServiceOrder];
//similar codes goes here..
}
else
{
NSLog(@"Orientation is LANDSCAPE");
//similar codes goes here..
}
}
}
我也有添加为iOS6的shouldAutorotateToInterfaceOrientation折旧以下,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
NSLog(@"Rotated!.");
}
- (BOOL)shouldAutorotate {
return YES;
}
- (NSInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return (UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait);
}
视图控制器加载在波泰特模式而已!.. 请指引我!