0
如何在iphone和ipad的ios6中爲不同的背景圖像設置不同的方向?現在,我設置圖像BG垂直如下,基於方向的UIView背景圖像
- (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;
}
我更新了我的問題。我試過,但它亙古不變的在我的代碼 – Fazil 2013-03-02 13:52:21
更新我的答案,PLZ再試一次修復任何概率。 – 2013-03-03 09:30:13