- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *CellIdentifier = @"ApplicationCell";
ApplicationCell *cell = (ApplicationCell *)[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
#if USE_INDIVIDUAL_SUBVIEWS_CELL
[[NSBundle mainBundle] loadNibNamed:@"IndividualSubviewsBasedApplicationCell" owner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
#elif USE_COMPOSITE_SUBVIEW_CELL
cell = [[[CompositeSubviewBasedApplicationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ApplicationCell"] autorelease];
#elif USE_HYBRID_CELL
cell = [[[HybridSubviewBasedApplicationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ApplicationCell"] autorelease];
#endif
}
// Display dark and light background in alternate rows -- see tableView:willDisplayCell:forRowAtIndexPath:.
cell.useDarkBackground = (indexPath.row % 2 == 0);
// Configure the data for the cell.
NSDictionary *dataItem = [data objectAtIndex:indexPath.row];
cell.icon = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]];
cell.publisher = [dataItem objectForKey:@"Publisher"];
cell.name = [dataItem objectForKey:@"Name"];
cell.numRatings = [[dataItem objectForKey:@"NumRatings"] intValue];
cell.rating = [[dataItem objectForKey:@"Rating"] floatValue];
cell.price = [dataItem objectForKey:@"Price"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *SimpleTableIdentifier = @"STI_SongsInfoCell"; //SimpleTableIdentifier
//定义"视图闲置组"标识符,可以是任意字符串,只要不冲突即可
myMusicInfoCellClass *cell = (myMusicInfoCellClass*)[tableViewdequeueReusableCellWithIdentifier:SimpleTableIdentifier];
//创建一个视图,从标识为"STI"的闲置视图组中。
//如果"STI"中有可用的闲置视图,则返回一个UITableViewCell,否则返回nil
if (cell == nil) { //如果cell=nil , 则表示sti中没有可用的闲置视图
//创建一个视图,表示这个同STI组里面的组是同一种类型
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SongsInfoCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[myMusicInfoCellClass class]])
cell = (myMusicInfoCellClass*)oneObject;
};
//到这里为止,UITableViewCell就创建好了呃,下面就用它
NSUInteger row = [indexPath row];
//NSLog(@"test = %@",SearchSongsList);
if ([SearchSongs objectAtIndex:row]==nil) {
return nil;
}
//设置cell的label标签
NSArray * myArr = [[SearchSongs objectAtIndex:row] componentsSeparatedByString:@"<分割>"];
//判断是否存在于播放列表之中,以确定AddedBtn是否可用
BOOL isAlreadyAdded = NO;
for (int i=0; i<[[myTbc playList] count]; i++) {
if ([[[[myTbc playList] objectAtIndex:i] objectAtIndex:3] isEqualToString:[myArrobjectAtIndex:3]]
) {
isAlreadyAdded = YES;
}
}
if (isAlreadyAdded==YES) {
cell.AddedBtn.enabled = NO;
} else {
cell.AddedBtn.enabled = YES;
}
cell.SongsName.text = [myArr objectAtIndex:0]; //从myArr数组里取元素
cell.SongsSinger.text = [myArr objectAtIndex:1];
cell.SongsAlbum.text = [myArr objectAtIndex:2];
cell.SongsInfo = (NSMutableArray*)myArr;
if ([[myArr objectAtIndex:4] hasSuffix:@".gif"]) {
if ([[myArr objectAtIndex:4] hasPrefix:@"d"])
cell.SongsSpeed.image= [UIImage imageNamed:[myArr objectAtIndex:4]];
};
cell.SongsSize.text = [myArr objectAtIndex:5];
cell.myPlayListTableView = myPlayListTableView;
cell.myTbc = myTbc;
cell.mySc = self;
if ([myPlayer.nowPlayDownPageURL isEqualToString:[myArr objectAtIndex:3]]) {
myPlayer.WorkingIndicatorView=cell.myaiv;
}
return cell;
}