标签:
iOS开发拓展篇—音频处理(音乐播放器2)
说明:该文主要介绍音乐播放界面的搭建。
一、跳转
// // YYMusicsViewController.m // #import "YYMusicsViewController.h" #import "YYMusicModel.h" #import "MJExtension.h" #import "YYMusicCell.h" #import "YYPlayingViewController.h" @interface YYMusicsViewController () @property(nonatomic,strong)NSArray *musics; @property(nonatomic,strong)YYPlayingViewController *playingViewController; @end @implementation YYMusicsViewController #pragma mark-懒加载 -(NSArray *)musics { if (_musics==nil) { _musics=[YYMusicModel objectArrayWithFilename:@"Musics.plist"]; } return _musics; } -(YYPlayingViewController *)playingViewController { if (_playingViewController==nil) { _playingViewController=[[YYPlayingViewController alloc]init]; } return _playingViewController; }
// YYPlayingViewController.h #import <UIKit/UIKit.h> @interface YYPlayingViewController : UIViewController //显示控制器 -(void)show; @end
YYPlayingViewController.m文件
// // YYPlayingViewController.m // #import "YYPlayingViewController.h" @interface YYPlayingViewController () - (IBAction)exit; @end @implementation YYPlayingViewController #pragma mark-公共方法 -(void)show { //1.禁用整个app的点击事件 UIWindow *window=[UIApplication sharedApplication].keyWindow; window.userInteractionEnabled=NO; //2.添加播放界面 //设置View的大小为覆盖整个窗口 self.view.frame=window.bounds; //设置view显示 self.view.hidden=NO; //把View添加到窗口上 [window addSubview:self.view]; //3.使用动画让View显示 self.view.y=self.view.height; [UIView animateWithDuration:0.25 animations:^{ self.view.y=0; } completion:^(BOOL finished) { window.userInteractionEnabled=YES; }]; } #pragma mark-内部的按钮监听方法 //返回按钮 - (IBAction)exit { //1.禁用整个app的点击事件 UIWindow *window=[UIApplication sharedApplication].keyWindow; window.userInteractionEnabled=NO; //2.动画隐藏View [UIView animateWithDuration:0.25 animations:^{ self.view.y=window.height; } completion:^(BOOL finished) { window.userInteractionEnabled=YES; //设置view隐藏能够节省一些性能 self.view.hidden=YES; }]; } @end
cell的点击事件中的处理代码:
/** * cell的点击事件 */ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //取消选中被点击的这行 [tableView deselectRowAtIndexPath:indexPath animated:YES]; //调用公共方法 [self.playingViewController show]; // //执行segue跳转 // [self performSegueWithIdentifier:@"music2playing" sender:nil]; }
标签:
原文地址:http://www.cnblogs.com/yipingios/p/5566714.html