UIButton as subitem in UILabel

I am trying to dynamically add UIbutton

as a subheading in a UIlable

. But I cannot press the button. It seems that the label does not resolve the buttonTapped event.
Can someone explain what exactly is going on here? and can anyone give me an alternative for this? thanks!

+2


a source to share


2 answers


funny i got the answer myself after 5 minutes of posting this question. It seems like I had to enable my UI on the labels.

i.e. -



lbl.userInteractionEnabled=YES;

      

+6


a source


Your question (and the subsequent answer) does not speak of wisdom (or lack of) what you are trying to do. UILabel

objects usually don't have to be interactive and put UIButton

as a sub-task on a label, just because you can do it doesn't sound quite like after Apple HIG for iPhone.



+2


a source







All Articles