避免UITableViewCell中的多个按钮发生内存泄漏的最佳方法 [英] Best way to avoid memory leaks for Multiple Buttons in UITableViewCell

查看:60
本文介绍了避免UITableViewCell中的多个按钮发生内存泄漏的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UITableViewCell中有一系列按钮. 我通过cellForRowAtIndexPath方法填充了所有这些内容,但是即使发布了所有内容,我的表视图也变得呆滞了.

I've got an array of buttons in a UITableViewCell. I populated them all through the cellForRowAtIndexPath method, but my tableview gets sluggish even though I have released everything.

我应该使用自定义UITableViewCell进行填充吗? 关于如何使用户尽可能平滑的任何建议都是很好的.

Should I be using a custom UITableViewCell to populate? Any suggestions on how to make this as smooth as possible for the user would be great.

下面的屏幕截图.

推荐答案

您可以为此特定单元格创建一个自定义单元格/自定义视图对,您可以在其中绘制drawRect:中的所有按钮.但是,这实际上会将所有按钮绘制为图像,因此您将无法点击它们,但是我想您始终可以为单元格创建一个UITapGestureRecognizer(您仍然必须通过检查来确定按下了哪个按钮x,y值).

You could create a custom cell / custom view pair for this specific cell, where you can draw all yours buttons in drawRect:. However, this would essentially draw all your buttons as an image so you wouldn't be able to tap them, but I guess you can always create a UITapGestureRecognizer to your cell (you'd still have to figure out which button was pressed by examining x,y values).

不过,在UITableViewCell中添加标记按钮没有任何意义.您可以在用户界面中提出另一种设计,即在表格顶部显示一个UIView,或者也可以使用模式控制器.

Still, I don't see any point in adding your tag buttons inside a UITableViewCell. You could come up for an alternate design in your UI, i.e. a UIView presented on top of the table, or a modal controller maybe.

这篇关于避免UITableViewCell中的多个按钮发生内存泄漏的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆