// // MusicList.m // 播放器 // // Created by apple on 14-7-24. // Copyright (c) 2014年 apple. All rights reserved. // #import "MusicList.h" #import "ViewController.h" @interface MusicList ()<UITableViewDataSource,UITableViewDelegate> { ViewController *viewCt; NSArray *musiclist;//歌曲名列表 } @end @implementation MusicList - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; UITableView *musicListTable=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain]; musicListTable.delegate=self; musicListTable.dataSource=self; [self.view addSubview:musicListTable]; // musiclist=[[NSArray alloc]initWithArray:[viewCt musiclist1]]; musiclist=@[@"Beyond-光辉岁月",@"G.E.M.邓紫棋-你把我灌醉",@"G.E.M.邓紫棋-回忆的沙漏 (国)",@"Beyond-海阔天空",@"Declan Galbraith-Tell Me Why"]; } #pragma mark-行数设置 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 5; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell==nil) { cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; } cell.textLabel.text=[NSString stringWithFormat:@"%@",musiclist[indexPath.row]]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // viewCt=[[ViewController alloc]init]; // [viewCt setIndex:indexPath.row]; [self.pCV setIndex:indexPath.row]; [self presentViewController:self.pCV animated:YES completion:^{ NSLog(@"进入播放页面"); [self.pCV play]; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end