沧州网站建设定制价格,企业做可信网站认证的好处,邯郸网站,wordpress实验室模板为了美化UI,想实现如下图的效果:点击高亮 出发点是好的。没想到#xff0c;出现了下图的连带问题:选择一行的时候#xff0c;竟然连带的出现了高亮效果 这个如何是好#xff1f;经过网络搜索#xff0c;发现我不是第一个遇到这样的问题#xff1a;custom-accessory-button…为了美化UI,想实现如下图的效果:点击高亮 出发点是好的。没想到出现了下图的连带问题:选择一行的时候竟然连带的出现了高亮效果 这个如何是好经过网络搜索发现我不是第一个遇到这样的问题custom-accessory-button-highlight-triggered-by-didselectrowatindexpath 1 UIButton *accessoryButton [UIButton buttonWithType:UIButtonTypeCustom]; 2 accessoryButton.frame CGRectMake(0, 0, 32, 32); 3 [accessoryButton setImage:[UIImage imageNamed:AccessoryButtonNormal.png] forState:UIControlStateNormal]; 4 [accessoryButton setImage:[UIImage imageNamed:AccessoryButtonInverse.png] forState:UIControlStateHighlighted]; 5 [accessoryButton addTarget:self action:selector(doAction:) forControlEvents:UIControlEventTouchUpInside]; 6 cell.accessoryView accessoryButton; 连使用方法都是一样的看来我不是第一个这么干的。这哥哥也不给解决办法不知道最后搞定没问题。困惑了一天以后终于让我找到了一条小缝隙,实现了下图的效果: 这个点击行的时候整行高亮是系统自带的功能没办法改变怎么办呢釜底抽薪在它高亮完以后再把效果取消这个出发点是对的可是浪费了大把的时间以后发现还是达不到预期的效果怎么呢查sdk的时候无意间发现UITablview有个willSelectRowAtIndexPath的方法吧。好吧这个willSelectRowAtIndexPath比didSelectRowAtIndexPath应该靠前吧在这里面试一下 1 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 2 UITableViewCell *Cell [tableView cellForRowAtIndexPath:indexPath]; 3 [(UIButton *)Cell.accessoryView setHighlighted:NO]; 4 return indexPath; 5 } 开始直接用的上面的代码发现好使靠人品后来想想即然在这个地方可以那就延时执行一下于是用了: - (void)mySelectRow:(UIButton *)actionBtn{ [actionBtn setHighlighted:NO]; } - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *Cell [tableView cellForRowAtIndexPath:indexPath]; [self performSelector:selector(mySelectRow:) withObject:(UIButton *)Cell.accessoryView afterDelay:0]; return indexPath; } 于是乎好使了! 转载自http://rainbird.blog.51cto.com/211214/687170转载于:https://www.cnblogs.com/pengyingh/articles/2339188.html