其iPhone
第一支持的接口方向以yourview.m文件中設置的所有接口 然後
在yourview.h文件
AppDelegate *appDel;
BOOL isShowingLandscapeView;
CGAffineTransform _originalTransform;
CGRect _originalBounds;
CGPoint _originalCenter;
BOOL isLand,touch;
-(void)viewWillAppear:(BOOL)animated
{
isLand = NO;
appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationNone];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
_originalTransform = [[appDelegate navigationController].view transform];
_originalBounds = [[appDelegate navigationController].view bounds];
_originalCenter = [[appDelegate navigationController].view center];
[appDelegate navigationController].view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
//[appDelegate navigationController].view.bounds = CGRectMake(0.0,20.0, 480.0, 320.0);
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(M_PI/2);
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +60.0, +80.0);
[[appDelegate navigationController].view setTransform:landscapeTransform];
[appDelegate navigationController].view.bounds = CGRectMake(-20.0,00.0, 480.0, 320.0);
[appDelegate navigationController].view.center = CGPointMake (240.0, 160.0);
}
if(result.height == 568)
{
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(M_PI/2);
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +124.0, +124.0);
[[appDelegate navigationController].view setTransform:landscapeTransform];
[appDelegate navigationController].view.bounds = CGRectMake(0.0,0.0, 568, 320.0);
[appDelegate navigationController].view.center = CGPointMake (284, 160.0);
}
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationLandscapeLeft;
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
[appDelegate navigationController].view.bounds = CGRectMake(0.0,0.0, 480.0, 320.0);
}
if(result.height == 568)
{
[appDelegate navigationController].view.bounds = CGRectMake(0.0,0.0, 568, 320.0);
}
// [appDelegate navigationController].view.bounds = CGRectMake(0.0,0.0, 480.0, 320.0);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else
{
return NO;
}
}
- (void) viewWillDisappear:(BOOL)animated {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate navigationController].view setTransform:_originalTransform];
[[appDelegate navigationController].view setBounds:_originalBounds];
[[appDelegate navigationController].view setCenter:_originalCenter];
if (isLand == NO) {
isLand = YES;
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
} else {
isLand = NO;
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
}
}
您將呈現/推送簽名控制器或其剛被添加爲子視圖? –
你只針對ios 6嗎? –
@Jennis作爲模態視圖呈現 –