且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

避免UITableViewCell中的多个按钮发生内存泄漏的***方法

更新时间:2022-06-07 08:45:48

您可以为此特定单元格创建一个自定义单元格/自定义视图对,您可以在其中绘制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.