【发布时间】:2014-12-28 13:34:47
【问题描述】:
我是 iOS 的新手.....我创建了一个表格视图以显示为联系人视图.....在这里我使用以下编码显示了姓名和号码,但我无法显示图像即使我使用了正确的代码.....请帮助我
names = [NSMutableArray arrayWithObjects:@"Karthick", @"Gopal", @"Suresh", @"Senthil", @"Guna",nil];
images = [NSMutableArray arrayWithObjects:@"per.png",@"per.png",@"per.png",@"per.png",@"per.png", nil];
num = [NSMutableArray arrayWithObjects:@"9568421301", @"8756324103", @"856472303", @"8796523565", @"9785858569",nil];
这是我的三个数组和
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [names count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
contactTableViewCell *cell = (contactTableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[contactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.name.text = [names objectAtIndex:indexPath.row];
cell.number.text = [num objectAtIndex:indexPath.row];
cell.conimage.image = [UIImage imageNamed:[names objectAtIndex:indexPath.row];
return cell;
}
【问题讨论】:
标签: ios objective-c cocoa-touch uitableview uiimageview