简体   繁体   中英

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.

//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

- (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. edit: but the color changes are wrong in there as well, take a look at UIViewController and didRotateFromInterfaceOrientation:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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