0
爲什麼setIndentationLevel
沒有獲取單元格子視圖? 我有一個UITableView
。我的cellForRowAtIndexPath
如下所示。我添加的箭頭沒有隨着文本標籤移動。爲什麼?setIndentationLevel不適用於cell.ContentView子視圖
我該怎麼做?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
UIImageView *img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"small_arrow.png"]];
img.frame = CGRectMake(5, 10, 7, 11);
[cell.contentView addSubview:img];
cell.textLabel.text=[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"name"];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:18];
[cell setIndentationLevel:[[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]];
return cell;
}
的NSLog( 「%@」,[[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@「level」] intValue]); ....請嘗試一下,看看你的consol會顯示什麼? – 2012-10-11 10:50:20
是的,我試過了。它顯示0,1,2,3等...... – Dev
然後你想爲你的cell.textLabel設置索引級別多少? – 2012-10-11 10:57:48