簡體   English   中英

iPhone iPad中的iOS 6調整

[英]iOS 6 oreiantation in iphone ipad

我如何在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"]];
}

它沒有顯示任何變化。 我只想在改變方向的同時改變背景? 誰能幫我解決一下嗎?

您必須將“ return”作為最后一個語句。 編輯:但是那里的顏色更改也是錯誤的,看一下UIViewController和didRotateFromInterfaceOrientation:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM