I am trying to dynamically add a UIbutton
as a subview to UIlable
. But I am not able to click the button. It seems that the label doesn't allow the buttonTapped event to occur.
Can somebody explain what exactly is happening here? and can anybody give me an alternative for this? thanks!
Asked
Active
Viewed 3,688 times
3

Alex Stanciu
- 5,183
- 2
- 24
- 31

Jayshree
- 281
- 1
- 6
- 28
-
1Maybe it would be a better idea to add both the `UILabel` and `UIButton` to a wrapper `UIVIew`? – texmex5 May 08 '10 at 08:31
2 Answers
2
Your question (and subsequent answer) don't speak to the wisdom (or lack thereof) of doing what you're attempting. UILabel
objects aren't generally meant to be interactive, and placing a UIButton
as a subview to the label, just because you can do it, doesn't sound at all like it's following the Apple HIG for iPhone.

WineSoaked
- 1,455
- 1
- 14
- 14
-
1
-
@Esq It is an answer! I had the same question. Now instead of using a UILabel, I'm changing it to a UIView which is probably a better way. – LevinsonTechnologies Sep 07 '15 at 21:05