设置ViewController方向
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
UIInterfaceOrientation barOrientation = [[UIApplicationsharedApplication] statusBarOrientation];
CGFloat angle = 0.0f;
switch (barOrientation) {
caseUIInterfaceOrientationPortrait:
angle = 0.0f;
break;
caseUIInterfaceOrientationPortraitUpsideDown:
angle = M_PI;
break;
caseUIInterfaceOrientationLandscapeLeft:
angle = M_PI / 2;
break;
caseUIInterfaceOrientationLandscapeRight:
angle = -M_PI /2;
break;
default:
break;
}
CATransform3D transform = CATransform3DMakeRotation(angle, 0, 0, 1.0);
self.view.layer.transform = transform;
}
return self;
}