gpt4 book ai didi

iphone - 当我点击表格 View 中的第一个单元格时,不会触发 didSelectRowAtIndexPath

转载 作者:行者123 更新时间:2023-12-03 21:00:03 25 4
gpt4 key购买 nike

当我点击表格 View 中的第一个单元格时,didSelectRowAtIndexPath 未触发...有人看到过这个和/或知道为什么会发生这种情况吗?我表格中的所有其他单元格都工作正常,我在 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];
}

感谢您的宝贵时间以及您能给我的任何帮助!

最佳答案

我认为您在第一行的 willSelectRowForIndexPath 中返回 nil 。这将阻止选择该行。

关于iphone - 当我点击表格 View 中的第一个单元格时,不会触发 didSelectRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1487183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com