//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了以后 虽然通过了 但是切换歌曲的时候没有暂停上一首歌.
问题较多 感谢各位指教小弟