2013-04-15 73 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