简体   繁体   中英

Adding UITableViewCell Image on button press

当我按下某个按钮时,是否可以将图像添加到UITableViewCell

根据文档https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html,UITableViewCell具有名为imageView的属性,该属性是UIImageView,意味着您需要做的所有事情要做的就是创建一个UIImageView并将UITableViewCell的imageView属性设置为UIImageView的属性。

Yes by creating a subclass of UITableViewCell, you can create tableviewcells in any format you want - Your subclass needs to know if the user pressed the button - many ways to do this - a plist, NSUserdefault or even a property in the TableViewCell subclass

Make sure your TableView delegate methods particularly CellForRowAtIndexpath calls your custom class.

Just [Tableview reloaddata] every time the button is toggled.

A good reference is the Elements sample app from apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM