Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-07-2008, 03:27 PM   #2 (permalink)
smasher
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by kieran12 View Post
Hey everyone. I have a UIImageView that I want to receieve an action. I want it to act like a button. It will not have an image set so it will be invisible, then when tapped i want it to change to an image.

I know that IBActions do not work on a UIImageView. How could I achieve this?


P.S I don't want to set the image property of a button it must be a UIImageView.
UIImageView inherits from UIControl - so look there to see how it can respond.

As far as I can see, you should not have to subclass UIImageView - just sent add another object as the target for any UIControlEventTouchUpInside events, using "addTarget:action:forControlEvents:"

iPhone Dev Center

Something like this: (Danger, I have not compiled this. Watch for typos.)
Code:
[myImageView addTarget:myController action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
myController should be an object that has a method "myAction: (id)sender" .
__________________

Free Games!

Last edited by smasher; 10-07-2008 at 03:43 PM. Reason: fix my @selector directive
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 386
12 members and 374 guests
2Apps1Day, Bryan1, cgokey, Domele, evilmatt10, flamingliquid, ipodphone, Miliguel1, nguyenhieu129, NSString, Objective Zero, williamWang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,565
Threads: 94,080
Posts: 402,749
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Miliguel1
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.