好的,我尽力解释我的问题,我尝试在用户从他们的设备中挑选图片后创建一个数组
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
listReceived = [NSArray arrayWithObjects:labelName.text,labelAddress.text,labelAge.text,@"filePicname.png",nil];
}
它可以重复多次(不止一次),所以我尝试把它放在 nsmutablearray
[allListReceived addObject:listReceived];
之后,我想通过使用自定义单元格在 uitableview 中显示所有内容。这是我尝试做的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TopCell";
MyCustomCell *cell = (MyCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
//topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"MyCustomCell-iPhone.xib" owner:nil options:nil];
}else{
topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"MyCustomCell-iPad.xib" owner:nil options:nil];
}
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (MyCustomCell *) currentObject;
cell.Label1.text = [allListTransfer objectAtIndex:indexPath.row];
cell.Label2.text = [allListTransfer objectAtIndex:indexPath.row];
cell.Label3.text = [allListTransfer objectAtIndex:indexPath.row];
cell.Label4.text = [allListTransfer objectAtIndex:indexPath.row];
cell.Label5.text = [allListTransfer objectAtIndex:indexPath.row];
break;
}
}
}
return cell;
}
是的,我知道 nsmutablearray 尚未使用,并且自定义单元格中的所有标签都是与数组第一个索引相同的字符串,我读到我必须使用 nsdictionary。但仍然没有运气。如果你们能帮助我,我真的很感激。
谢谢