0

iphoneとipadのios6で異なる向きに異なる背景画像を設定するにはどうすればよいですか? 今、私は次のように垂直の画像bgを設定し、

- (void)viewDidLoad
{
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ihome.png"]];
[super viewDidLoad];
}

次のコーディングにうんざりしていて、コード内に入ることさえありません

 -(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"]];
}
if (toInterfaceOrientation==UIInterfaceOrientationMaskPortrait)
{
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ihome.png"]];
}

return YES;

}

整理するのを手伝ってください

編集

- (BOOL)shouldAutorotate
{
return YES;
}

 - (NSUInteger)supportedInterfaceOrientations
  {
// return (UIInterfaceOrientationMaskAllButUpsideDown);
 return (UIInterfaceOrientationMaskAll);
 }

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeRight)
    
          self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];

if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeLeft)
   
         self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];

if (toInterfaceOrientation==UIInterfaceOrientationMaskPortrait)
  
       self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ihome.png"]];
     
       
  // return YES;
 }
4

1 に答える 1

0

アップルドキュメントから:

"shouldAutorotateToInterfaceOrientation: ビュー コントローラーが指定された向きをサポートしているかどうかを示すブール値を返します。( iOS 6.0 では非推奨supportedInterfaceOrientations。代わりにandpreferredInterfaceOrientationForPresentationメソッドをオーバーライドします。)"

- (BOOL)shouldAutorotate
{
if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeRight)

      self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];

if (toInterfaceOrientation==UIInterfaceOrientationMaskLandscapeLeft)

     self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lhomescreen.png"]];

if (toInterfaceOrientation==UIInterfaceOrientationMaskPortrait)

   self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ihome.png"]];


return YES;
}
于 2013-03-02T13:44:52.017 に答える