Reputation: 281
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!
Upvotes: 3
Views: 3696
Reputation: 281
funny, I got answer on my own after 5 mins of posting this question. It seems that I had to enable my userInteraction on the labels.
i.e. -
lbl.userInteractionEnabled=YES;
Upvotes: 6
Reputation: 1485
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.
Upvotes: 2