简体   繁体   中英

iOS: Using custom UITableViewCell vs. Using Cell viewWithTag?

Custom Cell For UITableViewCell

I'm developing an iOS application and i need to make a custom cell for my side menu, i have seen so many examples and i found out those two approaches :

  1. Make a class (.h and .m files) that inherits from UITableViewCell and put the outlets in the .h file then apply the class on the cell and connect those outlets to the labels and/or images from your cell in the storyboard.
  2. Or the easy way is to give a tag to the labels/images or whatever you have in the cell in your storyboard.

My Question : I'm wondering which way is more accurate and professional and used by most iOS developers ?

Definitely the first one. It's clear and maintainable in the future. The purpose of the tag is not to store arbitrary values. See my answer regarding this .

This article has some details on the usage of tags

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