0

如何在 ios6 中为 iphone 和 ipad 设置方向,我尝试了以下编码,它没有显示任何响应。

//以下由于已弃用的问题而无法正常工作

-(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;

}

// 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"]];
}

它没有显示任何变化。我只想在改变方向的同时改变背景?有人可以帮我解决吗?

4

1 回答 1

0

您必须将“return”作为最后一个语句。编辑:但是那里的颜色变化也是错误的,看看UIViewController和 didRotateFromInterfaceOrientation:

于 2013-03-02T12:22:51.990 回答