工作难点-1

来源:互联网 发布:超人软件倒闭 编辑:程序博客网 时间:2024/06/11 13:45

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

0 0
原创粉丝点击