【发布时间】:2014-01-17 15:52:16
【问题描述】:
我正在尝试在第 8 行的单元格文本旁边添加一个图像。我的问题是它没有进入(indexPath.row == 9) 方法,而我已经放置了断点,我从indexPath.row = {length = 2, path = 0 - 0} 获得了这个值。那么请问我的问题在哪里?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"cell"] autorelease];
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bakiyem-cell-bg.png"]];
img.x = 10.;
img.y = -6.;
[cell.contentView addSubview:img];
[img release];
//
cell.textLabel.font = [Constants regularFontWithSize:24.];
cell.textLabel.textColor = [Constants textGrayColor];
cell.detailTextLabel.font = [Constants mediumFontWithSize:24.];
}
cell.detailTextLabel.textColor = indexPath.row == 4 ? [UIColor colorWithRed:218./255. green:0 blue:37./255. alpha:1] : [Constants textGrayColor];
//My issue
if (indexPath.row == 9) {
cell.imageView.image = [UIImage imageNamed:@"info-logo.png"];
}
//
NSDictionary *dic = [data objectAtIndex:indexPath.row];
cell.textLabel.text = [dic objectForKey:@"value1"];
cell.detailTextLabel.text = [dic objectForKey:@"value2"];
return cell;
}
【问题讨论】:
标签: ios ipad uitableview