Iphone 折叠UITableView
嘿,各位,我在我的应用程序中创建了一个UITableView,当一个单元格被触摸时,它会扩展我遇到的问题是它不会崩溃无论我做了什么尝试,我确信这很容易,我只是想不出它崩溃的唯一时间是当它被另一个单元格点击时 这是我的密码:Iphone 折叠UITableView,iphone,objective-c,ios,uitableview,Iphone,Objective C,Ios,Uitableview,嘿,各位,我在我的应用程序中创建了一个UITableView,当一个单元格被触摸时,它会扩展我遇到的问题是它不会崩溃无论我做了什么尝试,我确信这很容易,我只是想不出它崩溃的唯一时间是当它被另一个单元格点击时 这是我的密码: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { selectedCellIndexPath = indexPath;
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectedCellIndexPath = indexPath;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
if (selectedCellIndexPath) {
selected = YES;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectedCellIndexPath != nil
&& [selectedCellIndexPath compare:indexPath] == NSOrderedSame)
return 150;
return 44;
}
您永远不会将
selectedCellIndexPath
更改为nil
,因此在选择新行之前不会更改当前选定行。在didselectrowatinexpath
中,应将开头更改为以下内容:
if (selectedCellIndexPath == indexPath)
selectedCellIndexPath = nil;
else
selectedCellIndexPath = indexPath;
您永远不会将
selectedCellIndexPath
更改为nil
,因此在选择新行之前不会更改当前选定行。在didselectrowatinexpath
中,应将开头更改为以下内容:
if (selectedCellIndexPath == indexPath)
selectedCellIndexPath = nil;
else
selectedCellIndexPath = indexPath;
我已经创建了正在折叠的UITableView http://www.codeproject.com/Articles/240435/Reusable-collapsable-table-view-for-iOS
它工作得很好 我已经创建了正在折叠的UITableView http://www.codeproject.com/Articles/240435/Reusable-collapsable-table-view-for-iOS
它工作得很好 调用行重新加载函数时,它是否进入cellForRow委托函数?如果是,则在检查所选行后,应使用一些功能折叠行。当调用行重新加载函数时,是否进入cellForRow委托函数?如果确实如此,则在检查选定行后,应使用一些功能折叠行。检查以下链接:-检查以下链接:-