【发布时间】:2012-03-12 07:13:30
【问题描述】:
提前致谢
我想检测我的设备的方向何时改变... 为此我使用了这个监听器
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
方向改变方法是
- (void) orientationChanged:(id)obj
{
if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight )
{
self.view=self.landscapeView;
NSLog(@"landscapeView");
//[self loadView1];
}
else
{
self.view = self.portraitView;
NSLog(@"portraitView");
//[self loadView1];
}
}
每次它进入 ViewDidLoad() 方法上的那个方向时......
谁能帮帮我..
【问题讨论】:
-
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 将在设备方向改变时调用
标签: iphone orientation screen-orientation orientation-changes