您的位置:首页 > 其它

工作难点-1

2015-09-27 18:53 465 查看
1、tableview的cell和btn绑定——cell点击出现不响应的方法:

首先从:以下入手

- (NSIndexPath *)tableView:(UITableView *)tv willSelectRowAtIndexPath:(NSIndexPath *)indexPath



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

其次要清楚

可能跟ios的消息传递有关,例如在TableView上增加一个button,点击button的时候,是不会调用tableView地didselelect事件。

这时候要想取得btn与cell 的联系,可以通过:

UIView* v=[btn superview].superview;//UITableViewCellContentView

UITableViewCell* cell=(UITableViewCell*)[v superview];//UITableViewCell

NSIndexPath* indexPath= [self.tableView indexPathForCell:cell];

OK搞定。

参见http://blog.csdn.net/kafeidev/article/details/9342101
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: