Iphone 方向不适用于toast视图

Iphone 方向不适用于toast视图,iphone,ipad,ios6,uiinterfaceorientation,Iphone,Ipad,Ios6,Uiinterfaceorientation,我已经包括了toast类,当我使用以下代码时,我已经将我的应用程序分配为iphone中的肖像和ipad中的风景 customView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 54)] autorelease]; [customView setBackgroundColor: UIColorFromRGB(0xda5340)]; UILabel *lb1=[[[UILabel alloc]initWithFrame:CGRect

我已经包括了toast类,当我使用以下代码时,我已经将我的应用程序分配为iphone中的肖像和ipad中的风景

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];
lb1.text=@"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" ];
 #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;
    }
}

 #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;
    }
}
在iphone中,它正确地显示在准确的位置

 #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;
    }
}
当我尝试使用ipad时,它垂直显示,如图所示

 #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;
    }
}

请帮我整理一下。

您好,对不起,我已经在ios 6.0的ipad和iphone中添加了您的代码,如果我们在视图中添加代码,并且我以这种方式更改了代码,那么它工作得非常好

 #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;
    }
}
#如果需要IPHONE操作系统版本最低版本<\uu IPHONE 6\u 0
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
if(UI\u USER\u INTERFACE\u IDIOM()==UIUserInterfaceIdiomPad){
返回UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
否则{
返回UIInterfaceOrientationSportRait(interfaceOrientation);
}
}
#恩迪夫
-(整数)支持的接口方向{
if(UI\u USER\u INTERFACE\u IDIOM()==UIUserInterfaceIdiomPad){
返回UIInterfaceOrientationMaskLandscapeRight;
}
否则{
返回UIInterfaceOrientationMaskPortrait;
}
}

您好,很抱歉,我已经在ios 6.0的ipad和iphone中添加了您的代码,并且工作正常。我上面的代码是在app delegate中,您是否尝试过app delegate或nor view?我上面的代码是在app delegate中,您是否尝试过app delegate或nor view?