【发布时间】:2016-02-23 07:20:03
【问题描述】:
我对 ios 比较陌生,谁能告诉我如何管理多个可变数组?例如:我有 3 个数组,其中一个数组用于图像,另外两个数组包含名称和描述,我想在 UITableView 单元格上显示
我试过这个,但它崩溃了。
image = [[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:@"demo_business_image@.png"], [UIImage imageNamed:@"demo_business_image@.png"], nil];
name = [[NSMutableArray alloc] initWithObjects:@"Dinner Bell Annouse 50% Discount on Punjabi Food!", nil];
time = [[NSMutableArray alloc] initWithObjects:@"13M", nil];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return image.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIImageView *img = (UIImageView *) [cell.contentView viewWithTag:720];
UILabel *lbl1 = (UILabel *) [cell.contentView viewWithTag:721];
UILabel *lbl2 = (UILabel *) [cell.contentView viewWithTag:722];
img.image = [image objectAtIndex:indexPath.row];
// lbl1.text=[name objectAtIndex:indexPath.row];
// lbl2.text=[time objectAtIndex:indexPath.row];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
return cell;
}
【问题讨论】:
-
什么是崩溃错误?
-
你能把你的崩溃日志贴在这里吗?
标签: ios objective-c iphone nsmutablearray