0
我正在表的每一行中添加一個活動指示器。這個問題是每次我滾動它重新添加在單元覆蓋前一個。請讓我知道哪些是在tableview單元格中添加控件的最佳方式。UITableView在iphone中添加控制問題
UIActivityIndicatorView *a;
//自定義表格視圖單元格的外觀。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
a = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[a startAnimating];
[cell.contentView addSubview:a];
// Configure the cell.
return cell;
}
非常感謝的正是這種「[cell.contentView viewWithTag:10]」我想知道。再次感謝 – iPhoneDev 2010-07-15 12:20:26