底线:我希望我的表格中的所有行/单元格在第一次查看时显示重新排序图标。第一个UITableView单元格/行不会显示重新排序图标
背景:在初始查看表格时,表格中的第0行(第一个单元格)不会显示重新排序图标,但后续单元格会显示它。我正在使用UITableViewCell构建我的表。 NSLog显示(见下文)编辑(允许重排序图标出现)最初没有对第0行启用,但是对于以后的行。将第0行滚动到视图之外后,返回到视图编辑处于启用状态,从而允许我查看重新排序图标(请参阅下面的NSLog)。我认为这可能是一个重用问题,但是我在所有行中都包含UILabels,以包含第0行,显示正常。我认为这是一个简单的解决方法,但只是无法弄清楚。任何帮助将不胜感激!
2011-03-13 12:48:57.750 VBSTAT [4305:207]行:0编辑:0 indexPath:81108000
2011-03-13 12:48:57.751 VBSTAT [4305:207]行:1编辑:1个indexPath:81108144
2011-03-13 12:48:57.752 VBSTAT [4305:207]行:2编辑:1个indexPath:81108224
2011-03-13 12点48: 57.753 VBStat [4305:207] row:3 editing:1 indexPath:81108304
2011-03-13 12:48:57.753 VBStat [4305:207] row:4 editing:1 indexPath:8110 8384
2011-03-13 12:48:57.754 VBSTAT [4305:207]行:5编辑:1个indexPath:81108464
2011-03-13 12:49:32.469 VBSTAT [4305:207]行:0编辑:1个indexPath:81108000
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellTableIdentifier = @"CellTableIdentifier ";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellTableIdentifier];
NSUInteger row = [indexPath row];
NSDictionary *rowData = [self.list objectAtIndex:row];
//stuff for labels...
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [rowData objectForKey:@"Name"];
UILabel *color = (UILabel *)[cell.contentView viewWithTag:kColorValueTag];
color.text = [rowData objectForKey:@"Color"];
if (cell == nil) {
{ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellTableIdentifier] autorelease];
NSLog(@"row: %i editing: %d indexPath: %d rowData %d", row, tableView.editing, indexPath, rowData);
...Labels generated here...
}
tableView.editing = YES;
cell.showsReorderControl=YES;
}
通过将tableView.editing移出if语句来修复0行编辑问题。现在在NSLog中显示0行编辑1,但它仍然不显示重新排序图标... uggg ... – groovedpavement
更多信息...做了另一个NSLog并观察了Debugger Console中的操作。注意到对于所有单元格,在初始视图中将showsReorderContol设置为0,我假设它并未设置,即使除第一个单元格(第0行)以外的所有单元格都出现重新排序控件。滚动发生后,对于所有行,重排序被设置为1,此时第0行的重排序控件出现。我现在假设我必须在其他地方插入cell.showReorderingControl,以便在表第一次出现时设置它,但是我在哪里插入它? – groovedpavement