Try the search, it's linked to some great forums

Saturday, July 16, 2011

Create an UIButton programatically

Include this in viewDidLoad to setup the basic button;
    [button addTarget:self  action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"Button" forState:UIControlStateNormal];
    button.frame = CGRectMake(20, 108, 97, 37);
    [self.view addSubview:button];

This button will do whatever is defined within the buttonPressed: method