1.添加监听函数
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(deviceOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
2.得到设备对象
-(void)deviceOrientationDidChange:(NSObject*)sender{
UIDevice* device = [sender valueForKey:@"object"];
NSLog(@"%d",device.orientation);
}
ios 监听设备方向发生改变
猜你喜欢
转载自wfkbyni.iteye.com/blog/1870934
今日推荐
周排行