iOS屏幕旋转相关

来源:互联网 发布:办公软件学习 编辑:程序博客网 时间:2024/06/10 19:59
supportedInterfaceOrientations设备支持方向

- (NSUInteger)supportedInterfaceOrientations{    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;}preferredInterfaceOrientationForPresentation 方法提供的择优的方向取向

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{    return UIInterfaceOrientationLandscapeLeft;}


ios5
重写 shouldAutorotateToInterfaceOrientation: 方法和指示您的视图支持哪个方向
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation{   if ((orientation == UIInterfaceOrientationPortrait) ||       (orientation == UIInterfaceOrientationLandscapeLeft))      return YES;    return NO;}监听屏幕方向变化
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];    [[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(orientationChanged:)                                                 name:UIDeviceOrientationDidChangeNotification                                               object:nil];
//处理旋转之后的操作
- (void)orientationChanged:(NSNotification *)notification
0 0
原创粉丝点击