添加侦听IPhone,ipad设备方向改变事件的方法
参考代码:
[[NSNotificationCenterdefaultCenter]
addObserver: self
selector:@selector(orientationChanged)
name:UIDeviceOrientationDidChangeNotificationobject:
nil];
/*
设备方向改变后添加的处理事件
*/
- (void) orientationChanged
{
UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];//获取当前设备的方向
}
/*
设备可能的方向
*/
typedefenum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down
} UIDeviceOrientation;
THE END!
2011-11-04