【发布时间】:2011-09-06 23:22:50
【问题描述】:
谁能告诉我这段代码有什么问题?我正在尝试确定设备所在的方向(纵向或横向)。谢谢。
- (void)checkOrientation
{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
switch (orientation)
{
case UIInterfaceOrientationPortrait:
self.tableView.backgroundColor = [UIColor whiteColor];
break;
case UIInterfaceOrientationPortraitUpsideDown:
self.tableView.backgroundColor = [UIColor whiteColor];
break;
case UIInterfaceOrientationLandscapeLeft:
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background2.png"]];
break;
case UIInterfaceOrientationLandscapeRight:
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background2.png"]];
break;
}
[self.tableView reloadData];
}
警告
从枚举类型“UIDeviceOrientation”到不同枚举类型“UIInterfaceOrientation”的隐式转换
【问题讨论】:
-
您收到了哪些警告?
-
Implicit conversion from enumoration type 'UIDeviceOrientation' to differnt enumeration type 'UIInterfaceOrientation
标签: iphone ios cocoa-touch ipad orientation