iOS开发拓展篇—音频处理(音乐播放器2)
说明:该文主要介绍音乐播放界面的搭建。
一、跳转





1 //
2 // YYMusicsViewController.m
3 //
4
5 #import "YYMusicsViewController.h"
6 #import "YYMusicModel.h"
7 #import "MJExtension.h"
8 #import "YYMusicCell.h"
9 #import "YYPlayingViewController.h"
10
11 @interface YYMusicsViewController ()
12 @property(nonatomic,strong)NSArray *musics;
13 @property(nonatomic,strong)YYPlayingViewController *playingViewController;
14 @end
15
16 @implementation YYMusicsViewController
17 #pragma mark-懒加载
18 -(NSArray *)musics
19 {
20 if (_musics==nil) {
21 _musics=[YYMusicModel objectArrayWithFilename:@"Musics.plist"];
22 }
23 return _musics;
24 }
25 -(YYPlayingViewController *)playingViewController
26 {
27 if (_playingViewController==nil) {
28 _playingViewController=[[YYPlayingViewController alloc]init];
29 }
30 return _playingViewController;
31 }




1 // YYPlayingViewController.h 2 3 #import <UIKit/UIKit.h> 4 5 @interface YYPlayingViewController : UIViewController 6 //显示控制器 7 -(void)show; 8 @end
YYPlayingViewController.m文件
1 //
2 // YYPlayingViewController.m
3 //
4
5 #import "YYPlayingViewController.h"
6
7 @interface YYPlayingViewController ()
8 - (IBAction)exit;
9
10 @end
11
12 @implementation YYPlayingViewController
13 #pragma mark-公共方法
14 -(void)show
15 {
16 //1.禁用整个app的点击事件
17 UIWindow *window=[UIApplication sharedApplication].keyWindow;
18 window.userInteractionEnabled=NO;
19
20 //2.添加播放界面
21 //设置View的大小为覆盖整个窗口
22 self.view.frame=window.bounds;
23 //设置view显示
24 self.view.hidden=NO;
25 //把View添加到窗口上
26 [window addSubview:self.view];
27
28 //3.使用动画让View显示
29 self.view.y=self.view.height;
30 [UIView animateWithDuration:0.25 animations:^{
31 self.view.y=0;
32 } completion:^(BOOL finished) {
33 window.userInteractionEnabled=YES;
34 }];
35 }
36 #pragma mark-内部的按钮监听方法
37 //返回按钮
38 - (IBAction)exit {
39 //1.禁用整个app的点击事件
40 UIWindow *window=[UIApplication sharedApplication].keyWindow;
41 window.userInteractionEnabled=NO;
42
43 //2.动画隐藏View
44 [UIView animateWithDuration:0.25 animations:^{
45 self.view.y=window.height;
46 } completion:^(BOOL finished) {
47 window.userInteractionEnabled=YES;
48 //设置view隐藏能够节省一些性能
49 self.view.hidden=YES;
50 }];
51 }
52 @end
cell的点击事件中的处理代码:
1 /**
2 * cell的点击事件
3 */
4 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
5 {
6 //取消选中被点击的这行
7 [tableView deselectRowAtIndexPath:indexPath animated:YES];
8
9 //调用公共方法
10 [self.playingViewController show];
11
12 // //执行segue跳转
13 // [self performSegueWithIdentifier:@"music2playing" sender:nil];
14 }
原文:http://www.cnblogs.com/LiLihongqiang/p/5699575.html