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 08-08-2010, 08:16 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default I can't believe I'm asking this...

Hi All,

It has been a while since I have worked on a project for the iPhone and I find that I am rusty as ever! I'm a noob all over again!! haha

All I am trying to do at the moment is put a little glow around a button after it is pressed. So simple an idea!

User presses button, imageView changes state from hidden to not hidden and then goes away after a few seconds.

The only problem I have at the moment is setting the center of the imageView (the glow) to the center of the button (a custom button).

Anyway, the code looks like

glowImage.centre = myButton.center;

Any ideas as to why this isn't working?

Cheers.
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 08-08-2010, 08:41 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by gabacus View Post
Hi All,

It has been a while since I have worked on a project for the iPhone and I find that I am rusty as ever! I'm a noob all over again!! haha

All I am trying to do at the moment is put a little glow around a button after it is pressed. So simple an idea!

User presses button, imageView changes state from hidden to not hidden and then goes away after a few seconds.

The only problem I have at the moment is setting the center of the imageView (the glow) to the center of the button (a custom button).

Anyway, the code looks like

glowImage.centre = myButton.center;

Any ideas as to why this isn't working?

Cheers.
You spelled center wrong for glowImage (at least wrong for iOS.) Are you a Brit? Centre, tyre, theatre, etc?
__________________
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 offline   Reply With Quote
Old 08-08-2010, 08:45 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

haha... yes, I did spell it wrong here, but the code has the right spelling (thank god for code completion!)

glowImage.center = myButton.center; // still doesn't work.

Oh, and I am from Australia by the way :-)
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 08-08-2010, 10:40 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 27
abhimanipal is on a distinguished road
Default

Let me see if I have understood your question correctly. You have a button and you want to set an image on top of the button. Maybe this piece of code will help you out

Code:
UIButton *button1= [UIButton buttonWithType:UIButtonTypeRoundedRect];
	UIImage *image1 = [UIImage imageNamed:@"greenLightSmall.png"];
	
	button1.frame= CGRectMake(10.0, 10.0, 100.0, 100.0);
	[button1 setTitle:@"Button1" forState:UIControlStateNormal];
	[button1 setImage:image1 forState:UIControlStateNormal];
I apologize if I did not get your question correctly
abhimanipal is offline   Reply With Quote
Old 08-08-2010, 11:38 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

no need to apologise for trying to help out!!

if there is any confusion its because i didnt ask the question properly!

i have set up the button in interface builder, not in code (this is my first experience with interface builder, i usually do everything by code...)

i dont want to change the button image, all i want to do is display another image on the screen when a button is pressed.

the code works fine in that an image is displayed with the button is pressed. my problem is that the button is in the wrong place.

i am trying to set the center of the image to the center of the button so that the image sits on top of the button (no change to the actually button image).

currently, when i push the button the image is displayed in the top left hand corner of the screen (default 0,0 coordinates).

does that make sense?
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 08-08-2010, 11:49 PM   #6 (permalink)
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 gabacus View Post
currently, when i push the button the image is displayed in the top left hand corner of the screen (default 0,0 coordinates).

does that make sense?
It does. I think you forgot to hook up the myButton outlet, so myButton.center is returning zero.

Throw a breakpoint on that line and mouse over myButton; is it nil or 0x0? If so I'm right. Or just open your .xib and check the myButton outlet.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 08-09-2010, 12:20 AM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

thats it!

i had connected up the outlets but later made changes to the artwork and didnt reconnect!

thank you so much for pointing that out... clearly, i need a little more experience with interface builder.

cheers
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 08-09-2010, 12:23 AM   #8 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

incidentally, I was also having trouble with my buttons not changing their image when they were being deactivated... I left that on the "to fix later" list but this solution also solved that problem... so double thank you!!
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   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: 333
10 members and 323 guests
arash5500, HemiMG, iram91419, linkmx, mediaspree, Objective Zero, Paul Slocum, stanny, Touchmint, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

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