Is using tag
in your UIView
to store the state of the UIView a bad practice?
For further actions, you may consider blocking this person and/or reporting abuse
Is using tag
in your UIView
to store the state of the UIView a bad practice?
For further actions, you may consider blocking this person and/or reporting abuse
Chakir Ayoub -
vc7 -
Shafayet Hossain -
Kudzai Murimi -
Top comments (6)
Yeah. Usually it is the last resort when it is very hard to manage view for whatever reason. As other answer suggests you may toggle some state variable on a view controller or the view itself if you can subclass it.
Thanks for the opinions :)
Can you elaborate more on that? What exactly are you using tag for in your UIView?
I have a customised video view and a fullscreen button in it. Both enter and exit fullscreen methods are linked to the outlet of the same fullscreen button. I toggle the tag of this button to 0 and 1 and according to its tag, I will decide whether to enter or exit the fullscreen. Is this an unreliable approach? If yes, then can you suggest a better one?
Why not a Bool var like isFullScreen in your view controller? Seems more clear to me, you toggle the variable and you know what you have to do
Thanks for the opinions :)