1

我已经包含了 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" ];

在此处输入图像描述在此处输入图像描述

在 iphone 中,它正确地显示在确切的位置。

当我尝试使用 ipad 时,它会像图像中一样垂直显示。

请帮我整理一下。

4

1 回答 1

0

嗨,对不起,但我已经在 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;
    }
}
于 2013-04-15T12:32:27.207 回答