在ios8中做的屏幕旋转功能
来源:互联网 发布:人工智能 百度网盘 编辑:程序博客网 时间:2024/04/30 08:18
http://www.cnblogs.com/smileEvday/archive/2013/04/24/Rotate2.html
思路出自这篇博主的文章。
直接上代码
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ NSLog(@"你旋转了"); if (toInterfaceOrientation ==UIInterfaceOrientationLandscapeLeft ) { [self addSegmentControl:UIInterfaceOrientationLandscapeLeft]; [self.segementControl_base addTarget:self action:@selector(clickOnSegment:) forControlEvents:UIControlEventValueChanged]; [self initData]; [self initLrc]; } else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { [self addSegmentControl:UIInterfaceOrientationLandscapeRight]; [self.segementControl_base addTarget:self action:@selector(clickOnSegment:) forControlEvents:UIControlEventValueChanged]; [self initData]; [self initLrc]; } else { [self addSegmentControl:UIInterfaceOrientationPortrait]; [self.segementControl_base addTarget:self action:@selector(clickOnSegment:) forControlEvents:UIControlEventValueChanged]; [self initData]; [self initLrc]; }}
通过给对应的segment传入当前的旋转状态来设置segment在旋转到不同的方向时加载的数据
-(void)addSegmentControl:(UIInterfaceOrientation)toInterfaceOrientation{ [self.segementControl_base removeFromSuperview]; NSArray *segmentArray = [NSArray arrayWithObjects:@"基本课文",@"应用课文" ,@"单词",nil]; UISegmentedControl * segmentControl = [[UISegmentedControl alloc]initWithItems:segmentArray]; self.segementControl_base = segmentControl;#warning 判断旋转方式 if(UIInterfaceOrientationLandscapeLeft == toInterfaceOrientation){ segmentControl.frame = CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height*0.1); }else if(toInterfaceOrientation == UIInterfaceOrientationPortrait){ segmentControl.frame = CGRectMake(0, 67, self.view.frame.size.width, self.view.frame.size.height*0.07); } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { segmentControl.frame = CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height*0.1); } segmentControl.selectedSegmentIndex = tags;// [segmentControl addTarget:self action:@selector(onSegmentedControlChanged:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:segmentControl];}
通过判断旋转方向来设置segment的大小,通过给不同的segment绑定不同的tags来确定相关的数据加载。
需要思考就是,全局变量是否应该使用的这么频繁。
接下来需要解决的问题就是音乐数据的打包和点击的时候切换到相关的事件点,就是监听cell的点击。
然后就看一下appsotre是否有一个推荐的功能,重复播放音乐的功能。
还有就是双语的功能,通过点击取消中文。随后就是看一些apple的源码,看一下对于数据的封装这一块是怎么做到的。
0 0
- 在ios8中做的屏幕旋转功能
- IOS8中屏幕旋转问题解决
- 如何做屏幕的旋转
- 屏幕旋转 iOS7 iOS8 通用版
- IOS8 旋转的问题
- 在WinCE中实现屏幕旋转
- win7电脑开启屏幕旋转功能吗 Win7系统屏幕的旋转功能如何使用
- 在做屏幕广播中遇到的问题
- iOS8定位问题,在iPhone设置中点击开启定位功能直接崩溃的问题
- IOS 关于IOS8屏幕的强制旋转与新的特性
- Activity在屏幕旋转时的生命周期
- jQuery旋转插件,做抽奖功能时在网速找的
- Settings添加屏幕旋转功能
- 如何删除ctrl+alt+方向键的旋转屏幕功能
- 在Unity中通过触摸屏幕实现模型的旋转和缩放
- 在Unity中通过触摸屏幕实现模型的旋转和缩放
- 在Unity中通过触摸屏幕实现模型的旋转和缩放
- iOS中关闭屏幕旋转功能时如何判断屏幕方向
- 在编译oc中protocol时出现的错误
- "this class is not key value coding-compliant for the key ..."问题的解决
- 关于Cannot assign to 'self' outside of a method in the init family解决方法
- 学习ios键盘和textfield之间操作体会
- 歌词加载学习笔记
- 在ios8中做的屏幕旋转功能
- 积累的 Android 开发各种开源库
- UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
- 封装实现一个自己的tabbar
- ios中strong和weak的解释理解
- duplicate symbols for architecture armv7解决办法
- 关于编程上的一些建议
- 关于block的一些理解
- Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptabl