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 一道python难题2
    • ¥15 一道python难题
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备