標籤:
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中做的旋轉螢幕功能