1
重複使用單元格時,是否可以將標籤添加到UITableViewCell?這是我一直在嘗試的代碼,但是當我向下滾動並且單元格被重用時,我的標籤四處移動。我只是希望標籤始終位於第一排,但我無法想象這是否適合我的生活。我知道我不能重複使用這些單元,它會工作,但我想重用這些單元。請幫我弄清楚這一點。非常感謝...重複使用單元格時向第一個UITableViewCell行添加標籤
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
}
if ([indexPath row] == 0) {
UILabel* Label = [[UILabel alloc] initWithFrame:CGRectMake(2,2, 62, 23)];
[Label setText:@"Text"];
[cell addSubview:Label];
[Label release];
}
return cell;
}