NickFaFa 2017-04-19 04:33 采纳率: 0%
浏览 511
已结题

OC的音乐播放器歌词问题


//TODO: 初始化歌词
-(void)initLRC{
    NSString *LRCPath=[[NSBundle mainBundle]pathForResource:musicNames[n] ofType:@"lrc"];
    NSString *contentStr=[NSString stringWithContentsOfFile:LRCPath encoding:NSUTF8StringEncoding error:nil];
    NSArray *array=[contentStr componentsSeparatedByString:@"\n"];
    for (int i=3; i<[array count]; i++) {
        NSString *lineStr=[array objectAtIndex:i];
        NSArray *lineArray=[lineStr componentsSeparatedByString:@"]"];

        if([[lineArray objectAtIndex:0] length]>5)
        {        NSString *lrcStr=[lineArray objectAtIndex:1];
            NSString* timeStr=[[lineArray objectAtIndex:0]substringWithRange:NSMakeRange(1, 5)];
            [LRCDictionary setObject:lrcStr forKey:timeStr];
            [timeArray addObject:timeStr];
        }

    }

    NSLog(@"LRCDictionar = %@",LRCDictionary);
    NSLog(@"timeArray = %@",timeArray);
}


-(void)deallocLrc{
    [LRCDictionary removeAllObjects];
    [timeArray removeAllObjects];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [timeArray count];
}
-(UITableViewCell *)tableView:(UITableViewCell *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier =@"LRCCell";
    UITableViewCell *cell=[_tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
    }
    cell.textLabel.text=[LRCDictionary objectForKey:[timeArray objectAtIndex:indexPath.row]];
    cell.textLabel.textColor=[UIColor blueColor];
    return cell;
}

这是我初始化歌词的代码. 但是在TableView中不显示.NSLog输出的也是空 (null)
最奇怪的是 为什么我切几首歌以后就也输出了 但是还是不显示在TableView上
最后一个问题就是 ..为什么我这样写了

 UITableViewCell *cell=[_tableView dequeueReusableCellWithIdentifier:cellIdentifier];

这一行的编译不通过
而我设置了ARC了以后 虽然通过了 但是切换歌曲的时候没有暂停上一首歌.

问题较多 感谢各位指教小弟

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)