简体   繁体   English

iPhone iPad中的iOS 6调整

[英]iOS 6 oreiantation in iphone ipad

How to set the orientation in ios6 for iphone and ipad, i tried with the following coding, its not showing any response. 我如何在ios6中为iPhone和iPad设置方向,我尝试了以下编码,但未显示任何响应。

//following not working because of deprecated issue //由于过时的问题而无法正常工作

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeRight)
  {
   self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];
  }
if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeLeft)
 {
  self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage     imageNamed:@"lhomescreen.png"]];
 }

 return YES;

}

// ios6 coding for ipad and iphone //适用于ipad和iphone的ios6编码

- (BOOL)shouldAutorotate
{
 return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
 self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];
}

it doesn't showing any change. 它没有显示任何变化。 i just want to change the back ground while change the orientation? 我只想在改变方向的同时改变背景? can any one please help me to sort it out? 谁能帮我解决一下吗?

You have to place "return" as the last statement. 您必须将“ return”作为最后一个语句。 edit: but the color changes are wrong in there as well, take a look at UIViewController and didRotateFromInterfaceOrientation: 编辑:但是那里的颜色更改也是错误的,看一下UIViewController和didRotateFromInterfaceOrientation:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM