我在app委托文件中添加了一个通知视图作为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中正常工作,当我在ipad中尝试不正确时,customView
被视为垂直。我还添加了以下代码,
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
我是否应该添加任何其他代码,请帮我解决
答案 0 :(得分:0)
最简单的方向初始设置是选择summary
标签,然后选择方向,如下图所示,