我在应用程序委托文件中添加了一个通知视图作为 toast 我添加为类代码,如下所示,
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 addSubview:customView];
[self.window showToast:customView duration:3.0 position:@"top" ];
我已将我的 ipad ipad 应用程序设置为横向,当我在 ipad 中尝试时,上述代码仅适用于 iphone,它的方向不正确,customView
被视为垂直。我还添加了以下代码,
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
如果我想添加任何其他代码,请帮我解决