xib 在UIView上拖拽了表格单元tableViewCell上去 还需要怎么做才能实现点击选择该表格单元,该表格单元会变灰色并响应某事件?
没搞清楚你要怎么样, Controller 实现代理
设置 tableView.delegate=self;
tableView.dataSource=self;
然后实现 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//在这个方法里就可以监听到 如果是不同的cell 响应不同的方法 如果位置固定的话 你可以这样做
if (indexPath.section==0) {
if (indexPath.row==0){
//....
}
}
}
或者你是需要这样的:
//添加关联的方法 Tap:
UITapGestureRecognizer *Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Tap:)];
Tap.numberOfTapsRequired = 1;//点击一次触发
Tap.numberOfTouchesRequired = 1;//点击需要的手指数量
[UIView addGestureRecognizer:Tap]; //
-(void)Tap
{
// do what you want
}
在view上加一层uibutton
你不能光拖tableViewCell, 还得有tableView......
你应该是想要这个 然后拿到cell进行处理吧,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
}
你直接拖了cell,那只是一个吧。拉线监听就好。
要是想多点cell,你就直接建立tableview视图,设置代理和数据源。然后在
竟然还没有解决吗。。。