您的位置:首页 > 其它

如何侦听iphone设备方向改变事件,以及如何添加事件的处理事件

2011-11-04 10:44 253 查看
添加侦听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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: