0

Is it possible to create a button inside a TableView in ios 6?

An example would be in Settings --> Mail, Calender... --> Click on an existing email account (on iPhone). At the bottom of this view there is a "button' saying delete account.

Is this a button or just another cell made to look like a button?

I want to keep the standard background that comes with a TableView which is why I'm inquiring. I know I could make the TableView shorter and add a normal button.

Thanks

Dan
  • 2,304
  • 6
  • 42
  • 69

2 Answers2

1

Check out my code on GitHub. https://github.com/eddieios/ECFormView

ECFormView uses a UITableView with a button added to the tableFooterView. I put the pertinent code below.

UIView *footerView = [[UIView alloc] init];
[footerView setFrame:CGRectMake(0, 0, 320, 100)];
self.tableView.tableFooterView = footerView;
[self.tableView sendSubviewToBack:footerView];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footerView addSubview:button];
[button setFrame:CGRectMake(10, 10, 300, 44)];
[button setTitle:@"Submit" forState:UIControlStateNormal];
//[button addTarget:self action:@selector(nextView:) forControlEvents:UIControlEventTouchUpInside];
Ed Chin
  • 1,214
  • 11
  • 24
0

You can do this by adding a button as a subview to the tableHeaderView or tableFooterView of a table view. This SO post describes some of the implementation: Adding a UIButton in the header of UITableView header

iOS 6 added a UITableViewHeaderFooterView class that implements a reusable view for headers and footers. This can improve performance when dealing with large table views. See: How to use UITableViewHeaderFooterView?

Community
  • 1
  • 1
Bryan Luby
  • 2,527
  • 22
  • 31