Adding a UIButton to a view programatically

Discussion in 'iOS Programming' started by seventoes, Jul 23, 2008.

  1. macrumors newbie

    Joined:
    Feb 5, 2008
    #1
    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?
     
  2. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    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?
     
  3. thread starter macrumors newbie

    Joined:
    Feb 5, 2008
    #3
    Doh. I'm dumb :(

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

    Sbrocket

    Joined:
    Jun 3, 2007
    Location:
    /dev/null
    #4
  5. thread starter macrumors newbie

    Joined:
    Feb 5, 2008
    #5
    Aha, i was wondering why the button liked to chill in the corner there, hehe.. Thanks for the tip!
     

Share This Page