I'm trying to do this but the button don't show:
// Create a Button to get Help
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ;
CGRect buttonRect = helpButton.frame;
// Calculate the top right corner
buttonRect.origin.x = self.tableView.frame.size.width - buttonRect.size.width - 8;
buttonRect.origin.y = self.tableView.frame.size.height - buttonRect.size.height - 8;
[helpButton setFrame:buttonRect];
[helpButton addTarget:self action:@selector(doHelp:)
forControlEvents:UIControlEventTouchUpInside];
[helpButton setEnabled:TRUE];
[self.tableView addSubview:helpButton];
what am I doing wrong?
UPDATE the fix code is here for anyone that is interested:
// Create a Button to get Help
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ;
CGRect buttonRect = helpButton.frame;
// CALCulate the bottom right corner
buttonRect.origin.x = self.view.frame.size.width - buttonRect.size.width - 8;
buttonRect.origin.y = buttonRect.size.height - 8;
[helpButton setFrame:buttonRect];
[helpButton addTarget:self action:@selector(doHelp:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:helpButton];
Select Touch Up Inside in the event drop-down list. In the Arguments drop-down list, you can select Sender or Sender And Event. Click Connect button, there will add a method in the ViewController source code.
try to add it to self.view not self.tableview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With