2013-04-15 72 views
1

工作,我有包括麪包類,我已分配在iPad的iPhone和景觀我的應用程序,人像,當我用下面的代碼方向不敬酒視圖

customView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 54)] autorelease]; 
[customView setBackgroundColor: UIColorFromRGB(0xda5340)]; 
UILabel *lb1=[[[UILabel alloc]initWithFrame:CGRectMake(10, 17, 180, 21)] autorelease]; 
[email protected]"Pet is out of boundary"; 
lb1.textAlignment = UITextAlignmentCenter; 
lb1.textColor=[UIColor whiteColor]; 
lb1.backgroundColor = [UIColor clearColor]; 
[customView addSubview:lb1]; 
[self.window showToast:customView duration:3.0 position:@"top" ]; 

enter image description hereenter image description here

在iPhone上運行其顯示正確的位置。

當我嘗試用ipad它顯示垂直像圖像。

請幫我整理一下。

+0

你好,很抱歉,但我在ipad和iphone中添加了你的代碼在ios 6.0中,它工作正常 –

+0

我的上面的代碼是在應用程序委託中,你嘗試使用應用程序委託還是查看? – Fazil

回答

0

你好,很抱歉,但我已經添加在iPad和iPhone的代碼在IOS 6.0,如果我們在視圖中添加的代碼,它正在完美,我以這種方式改變了代碼

#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 
     return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
    } 
    else{ 
     return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
    } 
} 
#endif 
-(NSUInteger)supportedInterfaceOrientations{ 
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 
    return UIInterfaceOrientationMaskLandscapeRight; 
    } 
    else{ 
     return UIInterfaceOrientationMaskPortrait; 
    } 
} 
+0

我上面的代碼是在應用程序委託中,您是否嘗試使用應用程序委託或查看? – Fazil