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条回答

    报告相同问题?

    悬赏问题

    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作