任何人都可以給我一個關於如何在一個UITableView中定義兩個自定義單元的想法嗎?一個單元應該只包含文本,而另一個包含視頻或圖像。高度也彼此不同。我需要的細胞就像如下─UITableview中的多個關節單元
這裏給定的圖像的代碼我的工作導通
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = @"tablecell";
static NSString *CellIdentifier2 = @"tablecell1";
if ([self.arrayAction isEqual:@"follow"])
{
ActivityFeedCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
[utilities roundedLayer:cell.sub_view.layer shadow:YES];
[utilities AddBorder:cell.updated_imgView];
cell.userName_label.text=[[[[[[_responseArray valueForKey:@"name"]objectAtIndex:indexPath.row]stringByAppendingString:@" "]stringByAppendingString:@"("]stringByAppendingString:[[_responseArray valueForKey:@"age"]objectAtIndex:indexPath.row]]stringByAppendingString:@")"];
cell.descriptionImg_label.text=[[_responseArray valueForKey:@"description"]objectAtIndex:indexPath.row];
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://tattoosingles.net/tattoouploads/%@",[_arrayname objectAtIndex:indexPath.row]]];
[cell.updated_imgView sd_setImageWithURL:url];
[utilities AddBorder:cell.updated_imgView];
cell.updated_imgView.layer.cornerRadius=5;
cell.updated_imgView.layer.masksToBounds = YES;
cell.userProfile_imgView.layer.mask = [self ChangeShape:cell.userProfile_imgView];
NSURL *url1 = [[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://tattoosingles.net/uploads/%@",[[_responseArray valueForKey:@"path"]objectAtIndex:indexPath.row]]];
[cell.userProfile_imgView sd_setImageWithURL:url1];
return cell;
}
else if ([self.arrayAction isEqual:@"tplike"])
{
ActivityFeedCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
[utilities roundedLayer:cell.sub_view.layer shadow:YES];
[utilities AddBorder:cell.updated_imgView];
cell.userName_label.text=[[[[[[_responseArray valueForKey:@"name"]objectAtIndex:indexPath.row]stringByAppendingString:@" "]stringByAppendingString:@"("]stringByAppendingString:[[_responseArray valueForKey:@"age"]objectAtIndex:indexPath.row]]stringByAppendingString:@")"];
cell.descriptionImg_label.text=[[_responseArray valueForKey:@"description"]objectAtIndex:indexPath.row];
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://tattoosingles.net/tattoouploads/%@",[_arrayname objectAtIndex:indexPath.row]]];
[cell.updated_imgView sd_setImageWithURL:url];
[utilities AddBorder:cell.updated_imgView];
cell.updated_imgView.layer.cornerRadius=5;
cell.updated_imgView.layer.masksToBounds = YES;
cell.userProfile_imgView.layer.mask = [self ChangeShape:cell.userProfile_imgView];
NSURL *url1 = [[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://tattoosingles.net/uploads/%@",[[_responseArray valueForKey:@"path"]objectAtIndex:indexPath.row]]];
[cell.userProfile_imgView sd_setImageWithURL:url1];
return cell;
}
else
{
ActivityFeedCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
cell.userName_label.text=[[[[[[_responseArray valueForKey:@"name"]objectAtIndex:indexPath.row]stringByAppendingString:@" "]stringByAppendingString:@"("]stringByAppendingString:[[_responseArray valueForKey:@"age"]objectAtIndex:indexPath.row]]stringByAppendingString:@")"];
cell.descriptionImg_label.text=[[_responseArray valueForKey:@"description"]objectAtIndex:indexPath.row];
// Configure cell
return cell;
}
}
,這裏是輸出上午getting-
請注意我對你的問題作出的修改。你的代碼不可讀,請保留格式,以便其他人可以回答你的問題 –
好的。我會牢記! – pri
我的答案是否適合你? – user3182143