Push一个横屏页面

[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight],使用此方法可强制性的转为横屏,但在3.0以后此方法是私有方法。所以,好的方法是通过view的transform来转为横屏。

	[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: YES];
    CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:duration];
	self.navigationController.view.transform = CGAffineTransformIdentity;
    self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI*(90)/180.0);
    self.navigationController.view.bounds = CGRectMake(0, 0, 480, 320);
	[UIView commitAnimations];


返回竖屏时,只需要在pop方法前,只需要把angle设为0.0旋转回去就可以了。

你可能感兴趣的:(C++,c,C#)