Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

seventoes

macrumors newbie
Original poster
Feb 5, 2008
28
0
Probably a noob question here, I'm still getting started with all of these cool new toys :D, but this doesnt seem to be working:

Code:
startButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[startButton setTitle:@"Start Game" forState:UIControlStateNormal];
startButton.bounds = CGRectMake(120, 200, 80, 20);
		
[self addSubview:startButton];
Am i missing something simple?
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
Where are you calling this? In which view? Is that the view being displayed? Have you used the debugger to see if your code is getting called?
 

seventoes

macrumors newbie
Original poster
Feb 5, 2008
28
0
Where are you calling this? In which view? Is that the view being displayed? Have you used the debugger to see if your code is getting called?

Doh. I'm dumb :(

Code wasnt even being called. Thanks for the little bump :p
 

seventoes

macrumors newbie
Original poster
Feb 5, 2008
28
0
You don't want to set the bounds of your button like you are - you want the frame.

Code:
startButton.frame = CGRectMake(120, 200, 80, 20);

Read this page for more info on the distinction:
http://developer.apple.com/document...ewsGuide/Coordinates/chapter_3_section_3.html

Keep in mind that 0,0 on the iPhone coordinate system is the top-left, not bottom-left (unlike is reflected in that article).

Aha, i was wondering why the button liked to chill in the corner there, hehe.. Thanks for the tip!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.