在ios8中做的屏幕旋转功能
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(, 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(, , self.view.frame.size.width, self.view.frame.size.height*0.07);
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
segmentControl.frame = CGRectMake(, 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的源码,看一下对于数据的封装这一块是怎么做到的。
在ios8中做的屏幕旋转功能的更多相关文章
- vue项目中图片预览旋转功能
最近项目中需要在图片预览时,可以旋转图片预览,在网上找了下,发现有一款功能强大的图片组件:viewerjs. git-hup: https://github.com/fengyuanchen/view ...
- win8中如何禁用屏幕旋转的快捷键
程序员通常会使用ctrl+alt+方向键 里编辑代码,特别对于使用eclipse的程序员,更是如此,但是win8却把这一快捷键给占用了,很不爽,如何办,很简单.直接上图: 2.但是发现禁用之后并没有解 ...
- 屏幕旋转时调用PopupWindow update方法更新位置失效的问题及解决方案
接到一个博友的反馈,在屏幕旋转时调用PopupWindow的update方法失效.使用场景如下:在一个Activity中监听屏幕旋转事件,在Activity主布局文件中有个按钮点击弹出一个Pop ...
- 【分享】迅为iTOP4412开发板-Android系统屏幕旋转设置
1.1概述 Android4.0,Androd4.4源代码能够编译成手机模式和平板模式,讯为iTop4412 开发平台 的Android系统默认编译为平板模式.客户须要依据自己的产品设计及应用环境,切 ...
- Runtime解决屏幕旋转问题
前言 大家或许在iOS程序开发中经常遇到屏幕旋转问题,比如说希望指定的页面进行不同的屏幕旋转,但由于系统提供的方法是导航控制器的全局方法,无法随意的达到这种需求.一般的解决方案是继承UINavrgat ...
- Android设置屏幕旋转后保存数据
1.onCreate()方法中最后判断需要保存的状态值 if(savedInstanceState != null){ mCurrentIndex = savedInstanceState.getIn ...
- Android动态禁用或开启屏幕旋转工具
package com.gwtsz.gts2.util; import android.content.Context; import android.provider.Settings; impor ...
- WPF中使用AxisAngleRotation3D实现CAD的2D旋转功能
原文:WPF中使用AxisAngleRotation3D实现CAD的2D旋转功能 对于CAD图形来说,3D旋转比较常用,具体实现方法在上篇文章<WPF中3D旋转的实现 >中做了 ...
- 【转】如何在 Android 程序中禁止屏幕旋转和重启Activity
原文网址:http://www.cnblogs.com/bluestorm/p/3665890.html 禁止屏幕随手机旋转变化 有时候我们希望让一个程序的界面始终保持在一个方向,不随手机方向旋转而变 ...
随机推荐
- 第三节 构造一个简单的Linux系统MenuOS——20135203齐岳
第三节 构造一个简单的Linux系统MenuOS By 20135203齐岳 Linux内核源代码 arch/ 支持不同cpu的源代码 Documentations/ 文档存储 init/ 内核启动相 ...
- guacamole 0.8.3 项目部署 桌面虚拟化
Guacamole是一个基于HTML5的虚拟桌面应用程序,其中包含多个组件,由各组件共同构成Guacamole---一个完整的虚拟桌面解决方案,不需要任何插件,只要浏览器支持HTML5就可以实现,而且 ...
- android单选框和复选框(练习)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- 监听器初始化Job、JobTracker相应TaskTracker心跳、调度器分配task源码级分析
JobTracker和TaskTracker分别启动之后(JobTracker启动流程源码级分析,TaskTracker启动过程源码级分析),taskTracker会通过心跳与JobTracker通信 ...
- vertical-align及IE7下的inline-block
在IE7下,是不支持inline-block元素的,当对块级元素如dl进行inline-block样式设置时,在IE7浏览器是下样式是不会生效的. 若要在IE7下实现将块级元素设置为内联元素,可以这样 ...
- 前台发送字符串给后台,格式为(a,b,c,d),后台将字符串转换成数组遍历后进而更新CheckId
using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Configuration; u ...
- AngularJs的UI组件ui-Bootstrap分享(四)——Datepicker Popup
Datepicker Popup是用来选择日期的控件,一般和文本框一起使用,功能和Jquery的插件My97DatePicker一样.在Datepicker Popup内部使用了ui-bootstra ...
- DOM优化
一:DOM与浏览器: 重排:改变页面的内容. 重绘:浏览器显示的内容. 添加顺序:尽量在appendchild之前. 合并DOM操作-利用csstext, 缓存布局信息 文档碎片. 二 DOM 与事件 ...
- Unity3D和OGRE资源管理机制
转自:http://www.tuicool.com/articles/QbMjUn 游戏中通常有大量资源,如网格.材质.纹理.动画.着色器程序和音乐等,游戏引擎作为做游戏的工具,自然要提供良好的资源管 ...
- Python OpenCV —— Modifying
一些索引和修改图像像素点数据等的操作,可打印观察运行结果. # -*- coding: utf-8 -*- """ Created on Wed Sep 28 00:11 ...