场景:

子类化Cell中有button,拥有选中式样,点击第一个Cell中的button后,Cell一中的button获得选中式样。可是当点击Cell二中的button时。Cell一中的button选中式样依旧存在,即同一时候存在两个选中的button。

解决方法:

在子类化的Cell中,定义一个

static UIButton *selectedButton;

必须是 static 静态变量。



然后在点击方法中。

 - (void)headerButtonClickAction:(UIButton *)btn
{
selectedButton.layer.borderWidth = 0;
btn.layer.borderWidth = 2;
selectedButton = btn;
}

这种话我就能取到上次点击的button,

我设置的是边框宽度显示是否选中。自己能够依据自己的需求写demo。

这里要不用操心第一次运行时selectedButton为nil,为nil时。不会对程序产生影响。

最新文章

  1. 两年来的core折腾之路几点总结,附上nginx启用http2拿来即用的配置
  2. Microsoft Dynamics AX 2012: How to get Company,Customer and Vendor address in AX 2012
  3. 决策树 -- ID3算法小结
  4. 程序间数据共享与传递:EXPORT/IMPORT、SAP/ABAP Memory
  5. 第一百九十二天 how can I 坚持
  6. [转载]开机出现A disk read error occurred错误
  7. ZOJ Problem Set - 3758 素数
  8. selenium.common.exceptions.TimeoutException: Message: Screenshot: available via screen
  9. java多态 -- 猫狗案列
  10. 【Unity】Unity中C#与Android中Java的互相调用遇到的一些问题
  11. 15.C++-操作符重载
  12. 双向数据绑定原生js
  13. visual studio vode 汉化
  14. Windows Server2008 R2安装wampserver缺少api-ms-win-crt-runtime-l1-1-0.dll解决方案
  15. Python实现工厂模式
  16. 腾讯云cos封装
  17. Android 由 android:launchMode="singleInstance“引发的界面无法返回的情况
  18. swift类型转换之Could not cast value of type xxx to xxx错误的一种特殊情况记录
  19. Android开发:《Gradle Recipes for Android》阅读笔记(翻译)6.2——DSL文档
  20. IE回车的一个怪异行为

热门文章

  1. Lightoj-1356 Prime Independence(质因子分解)(Hopcroft-Karp优化的最大匹配)
  2. Ubuntu开机启动的方式
  3. Html5+CSS
  4. Maven / Nexus 的用法和经验
  5. POJ 1236 Network of Schools(SCC)
  6. 使用jQuery操作DOM(ppt练习)
  7. BigDecimal的精度舍入模式详解
  8. vue中的组件,Component元素,自定义路由,异步数据获取
  9. [Java基础] Java多线程-工具篇-BlockingQueue
  10. iOS:使用集成的支付宝SDK的支付流程