在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 禁止屏幕随手机旋转变化 有时候我们希望让一个程序的界面始终保持在一个方向,不随手机方向旋转而变 ...
随机推荐
- 樱花漫地集于我心,蝶舞纷飞祈愿相随---总结 顕出:void-sampling 显示:void-sampling
知识点: 分支语句,四则运算,( ̄y▽ ̄)~* 实验过程中遇到的问题及解决方法: 忘记换行,忘记代码,输入法切换(´∀`*) 暂时还得照书写,*★,°*:.☆\( ̄▽ ̄)/$:*.°★* 实验心得体会 ...
- 20135203齐岳信息安全系统设计基础——实验四&实验五实验报告
见20135217孙小博的博客:http://www.cnblogs.com/sunxiaobo/p/4991861.html
- PHP基础示例:商品信息管理系统v1.1[转]
实现目标:使用php和mysql写一个商品信息管理系统,并带有购物车功能 一.创建数据库和表 1.创建数据库和表:demodb 2.创建表格:goods 字段:商品编号,商品名称,商品类型,商品图 ...
- MySQL与SqlServer中update操作同一个表问题
一 SqlServer中操作如下图 这个是没问题的. 二 MySQL中操作如下图 但是在MySQL中想实现这个功能如下图,但是出错了. 原来是MySQL中不支持子查询的 我们可以这样修改一下就可以实现 ...
- 【USB多路电源】---需求分析方案制定
需求描述: USB接口输入5V,分别输出±5V,100mA; 3.3V,100mA: 1.2V,500mA:四路电源.同时可给锂电池充电,在移除USB输入时锂电池能供电. 分析: 首先考虑需要一个充电 ...
- Client默认用户及登录密码(转)
Client默认用户及登录密码 SAP系统(如ERP.CRM等)安装完成,初始化状态下有若干个客户端(Client).如果是生产系统,一般只有000.001.066等三个Client:如果是IDES系 ...
- C#深度拷贝和浅度拷贝方法
C#浅度拷贝多用于值类型的复制,即 int a=1;int b=a; 设置b=2后不会影响a的值. 但如果对于引用类型class a=new class(); class b=a; 设置b.name= ...
- Hadoop 2.2.0学习笔记20131209
1.下载java 7并安装 [root@server- ~]# rpm -ivh jdk-7u40-linux-x64.rpm Preparing... ####################### ...
- IDH2.5.1. Pain Points
1. On Redhat 6.2 after uninstalling a cluster, and re-install IDH 2.5.1, you meet a "can not wr ...
- MJRefresh的一个注意事项
如果从视图一跳转到视图二之后,在视图二中进行MJRefresh的刷新操作,那么在推出试图二之前要用dealloc函数将MJRefreshHeaderView或者MJRefreshFooterView释 ...