在ios8中做的旋轉螢幕功能

來源:互聯網
上載者:User

標籤:

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的源碼,看一下對於資料的封裝這一塊是怎麼做到的。

 

在ios8中做的旋轉螢幕功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.