将图像加载到一个单元格UITableView - xcode

TMB*_*B87 0 iphone xcode objective-c ios

我有两个信息数组,我通过以下内容加载到UITableView控件:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    if(indexPath.section == 0)

        cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];

    else
        cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryNone;
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

我想要在其下面的顶部数组(arryTableData)作为第一个单元格的位置图像.

arryTableData = [[NSArray alloc] initWithObjects:[NSString stringWithFormat:@"%@", locName],
                            [NSString stringWithFormat:@"%@", locPhone],
                            @"Address Info",
                            @"Access Icons",
                            nil];
Run Code Online (Sandbox Code Playgroud)

所以就在locName之前我希望locImage在那里.如何将图像加载到数组中,然后将其显示在单元格中?

谢谢

汤姆

Jon*_*lli 5

我建议不要将UIImage加载到NSArray中.只需将"ImageName"(文件名)作为NSString添加到NSArray中.

当您需要显示图像时,请执行以下操作:

UIImage * image = [UIImage imageNamed:[arryTableImage objectAtIndex:indexPath.row]];
cell.imageView.image = image;
Run Code Online (Sandbox Code Playgroud)

您需要将NSString加载到NSArray arryTableImage中.

好的,你呢?