How to enable void “didSelectRowAtIndexPath” and disable it?

↘锁芯ラ 提交于 2020-01-02 23:14:37

问题


I search didSelectRowAtIndexPath this key word

And found most problem is how to trigger it

But my question is how to enable it with another conditions

You can check my last question here - How to add a radio button in tableview

how To disable this void when the radio button is not selected ???

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}


回答1:


I'm a bit confused by your question, but from what I can tell, you want to prevent a tableView row from being selected under certain conditions? For that you'll want to use tableView:willSelectRowAtIndexPath:. If you return nil from that method the tableView will not select a row. You may find it helpful to read the documentation for UITableViewDelegate.




回答2:


Well I guess you need to run the code within the method conditionally. If your radiobutton is enabled, just run it, if not, return nil (or the other way round). You cannot prevent the method from being called at all, however.




回答3:


according to your radio button state set the cell property

cell.userInteractionEnabled = NO;


来源:https://stackoverflow.com/questions/4244675/how-to-enable-void-didselectrowatindexpath-and-disable-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!