当我点击我的tableview第一小区didSelectRowAtIndexPath
不会被触发......有没有人似乎这和/或有任何线索,为什么出现这种情况?我表格中的所有其他单元格都工作得很好,我在我的代码中放置了一个断点didSelectRowAtIndexPath
如果第一个单元格被轻敲,应用程序就不会进入该代码,但是如果任何其他单元格被点击,该代码将进入代码。 下面是一些代码:当我点击我的tableview didSelectRowAtIndexPath方法的第一个单元格,则不会触发
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = 0;
return row;
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = [indexPath row];
if (row == 0)
return nil;
return indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSUInteger row = [indexPath row];
//NSString *rowValue = [poolListData objectAtIndex:row];
int newRow = [indexPath row];
int oldRow = [lastIndexPathForPoolList row];
if (newRow != oldRow)
{
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPathForPoolList];
oldCell.accessoryType = UITableViewCellAccessoryNone;
lastIndexPathForPoolList = indexPath;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (NSInteger)tableViewForDelete:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [poolListData count];
}
- (UITableViewCell *)tableViewtableViewForDelete:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:DeleteMeCellIdentifier] autorelease];
}
NSInteger row = [indexPath row];
cell.text = [self.poolListData objectAtIndex:row];
return cell;
}
#pragma mark -
#pragma mark Table View Delegate Methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
[self.poolListData removeObjectAtIndex:row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
感谢您的时间和任何帮助,您可以给我!
对不起这个烂摊子......我似乎无法获得正确粘贴的代码。 – Jeff 2009-09-28 13:58:26
纠正了你。 lastindexpathforpoollist initializerd在哪里? – ennuikiller 2009-09-28 14:01:50
你设置了tableview.delegate吗? – CiNN 2009-09-28 14:03:38