问题描述
我的UITableViewController具有SettingsViewController的类名称.它包含一个链接到UITableViewCell的属性,称为signOutCell.
My UITableViewController has the class name of SettingsViewController. It contains a property linked to a UITableViewCell called signOutCell.
为什么这不能识别用户是否触摸了signOutCell?它在SettingsViewController.m里面吗?
Why does this not recognize if a user has touched the signOutCell? It is inside SettingsViewController.m?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([touches containsObject:signOutCell])
{
[self triggerActionSheetConfirmation];
}
}
我放了
NSLog(@"Received touch");
在if语句之前,但从未被调用.在此TableViewController中触摸任何东西时,touchesBegan:withEvent:永远不会被调用吗?
before the if statement, but it never got called. Is touchesBegan:withEvent: never getting called when anything is touched in this TableViewController?
如何在UITableViewCell中简单点击以调用triggerActionSheetConfirmation方法?
How can I get a simple tap in a UITableViewCell to call the method triggerActionSheetConfirmation?
推荐答案
使用UITableViewDelegate
方法tableView:didDeselectRowAtIndexPath:
.在该方法中,通过UITableView
方法cellForRowAtIndexPath
获取单击的行的单元格.然后,使用if
语句将单元格与您创建的UITableView
插座属性进行比较.然后运行您的方法(如果它对该出口有帮助).
Use the UITableViewDelegate
method tableView:didDeselectRowAtIndexPath:
. In that method get the cell of the row clicked via the UITableView
method cellForRowAtIndexPath
. Then use an if
statement to compare the cell with the UITableView
outlet property you created. Then run your method if it evaluates to that outlet.
这篇关于为什么我的UITableView无法识别UITableViewCell内部的触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!