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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-09-2011, 03:35 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default Making UIImageView Clickable

Hello,

Right now I am working on a menu for a game. Instead of buttons (UIButton) I would like to use images made in photoshop as clickable menu items. UIButton does not allow me the movement to design menu items as I want to (PS. I am a beginner so I don't know many details).

So my question is: how can I make an image clickable so that it behaves in the same way as a button?

Thanks a lot!

Last edited by BrightMedia; 12-10-2011 at 11:36 AM.
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 03:45 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
UIButton does not allow me the movement to design menu items as I want to
Uh, what?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 03:46 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Uh, what?
It can? Can you please tell me how?
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 03:47 PM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
Hello,

Right now I am working on a menu for a game. Instead of buttons (UIButton) I would like to use images made in photoshop as clickable menu items. UIButton does not allow me the movement to design menu items as I want to (PS. I am a beginner so I don't know many details).

So my question is: how can I make an image clickable so that it behaves in the same way as a button?

Thanks a lot!

- Patrick
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.

Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 12-09-2011, 03:47 PM   #5 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I don't understand the limitation you are describing. Try again.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 03:55 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
I don't understand the limitation you are describing. Try again.
Hi,

Let me give it another try.

I would like to use an image as menu item. I made this image in Photoshop. As far as I know, images usually can't be clickable like buttons can.

When clicking on this image, the game should display another screen.

The problem is just that I don't know how to make this image clickable.

Please don't forget that I'm still learning this stuff so I might be talking about things I don't know much about.
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 03:56 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.

Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
Thanks! I am going to read more about this
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 03:57 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
Hi,

Let me give it another try.

I would like to use an image as menu item. I made this image in Photoshop. As far as I know, images usually can't be clickable like buttons can.

When clicking on this image, the game should display another screen.

The problem is just that I don't know how to make this image clickable.

Please don't forget that I'm still learning this stuff so I might be talking about things I don't know much about.
No, I mean explain why you think you can't use a UIButton.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 04:00 PM   #9 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
No, I mean explain why you think you can't use a UIButton.
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 04:02 PM   #10 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.

Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
Thanks again for your solution! I read more about this but I'm having the following question:

How do I connect the image with the method UITapGestureRecognizer?
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 04:15 PM   #11 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
Not true at all.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 04:15 PM   #12 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
It wont. You can set your image as the button's image and it will be fine. Just set the type to Custom.
baja_yu is offline   Reply With Quote
Old 12-09-2011, 04:46 PM   #13 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 36
BrightMedia is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
It wont. You can set your image as the button's image and it will be fine. Just set the type to Custom.
It worked, thanks a lot everybody!
BrightMedia is offline   Reply With Quote
Old 12-09-2011, 08:06 PM   #14 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by BrightMedia View Post
Thanks again for your solution! I read more about this but I'm having the following question:

How do I connect the image with the method UITapGestureRecognizer?
I should have read your original post more carefully. A custom button is an easier way to do this, for sure.

Knowing how to use a gesture recognizer is good too. In order to present an image on the screen, you usually put it in a UIImageView.

You would attach the gesture recognizer to the image view. you can make labels and other things clickable that way, which can be handy.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 413
13 members and 400 guests
7twenty7, AppsBlogger, David-T, Duncan C, EvilElf, HemiMG, heshiming, iekei, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0