1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Adding a UIButton to a view programatically

Discussion in 'iPhone/iPad Programming' started by seventoes, Jul 23, 2008.

  1. macrumors newbie

    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:

    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

    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. macrumors newbie

    Doh. I'm dumb :(

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


  5. macrumors newbie

    Aha, i was wondering why the button liked to chill in the corner there, hehe.. Thanks for the tip!

Share This Page