• 在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(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的源码,看一下对于数据的封装这一块是怎么做到的。

    纸上得来终觉浅,绝知此事要躬行
  • 相关阅读:
    hadoop2.0.x【3】--Yarn Commands
    hadoop2.0.x【2】--Apache Hadoop MapReduce
    hadoop2.0.x【1】--Apache Hadoop NextGen MapReduce (YARN)--翻译与分析
    基于jquery的提交、编辑页面js编写框架
    UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7
    Protecting resources in iPhone and iPad apps
    使用Xcode 5创建Cocoa Touch Static Library(静态库)
    Example of how to implement a view-based source list (NSOutlineView) using Cocoa Bindings
    转载:收费版APP三年总结(个人经验+数据图分享)
    OC 导入类 #import和@class 区别
  • 原文地址:https://www.cnblogs.com/asheng/p/4382137.html
Copyright © 2020-2023  润新知