Hello again. I am wondering if anyone has used the userInteractionEnabled method on a UILabel to allow the label to act like a button (or just to fire off a method). Any help would be greatly appreciated. Cheers!
Update (4/30/09 @1:07pm) Clarification: I have a standard InfoButton and next to it I want to place a label with the text "settings" and I would like the label to function like the button (which flips over to a settings screen. So, basically I need to tie the already defined showSettinsView to the "infoLabel" label; a user clicks on the infoButton or infoLabel and the method fires off.
The infoButton is already working and is using an IBAction to trigger the method. I would like to know how to wire up the label to implement the same method. That is all. Cheers!
-
userInteractionEnabled
is not a method but a property. But I think you will want to set this toYES
to allow events to get through to theUIView
superview.What you might want to do is override the
touchesBegan:withEvent:
method of theUIView
that contains yourUIButton
andUILabel
subviews.Within this method, test if any of the
UITouch
touches fall inside the bounds of theUILabel
.That is, does the
CGPoint
element[touch locationInView]
intersect with with theCGRect
element[infoLabel bounds]
? Look into the functionCGRectContainsPoint
to run this test.If so, then fire off an
NSNotification
that calls the sameIBAction
selector as theUIButton
.Kevin Bomberry : Thanks Alex, I'll go ahead and try it and see what I can do. Cheers! -
Another solution could be to use a
UIButton
with its type set to custom, instead of aUILabel
. This way your second button will look like aUILabel
, and you can configure it to trigger theshowSettingsView
method.fyasar : That's is really good trick. -
yes godart is right this way u can make a button look like label and also can glow it
0 comments:
Post a Comment