How do I add a round rect button outside of a cell in a UITableView?
For example :
The "Other","home" & "home" fields are all independent cells.
What I am trying to achieve is the ability to add buttons such as the "Text Message","Share Contact" & "Add to favorites" shown above.
Thanks in advance for the advice!
Simply add a footer (or header) to the appropriate section.
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *yourView = [[UIView alloc] initWithFrame:CGRectMake(x,x,x,x)];
UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
yourButton.frame = CGRectMake(x,x,x,x);
[yourButton setTitle:@"Title" forState:UIControlStateNormal];
[yourView addSubview:yourButton];
return yourView;
}
Basically there are two options within regular UITableViews.
tableView:viewForHeaderInSection:
method and provide an appropriate header with buttond and whatever you like. This one, too, shold have a transparent background. You need a custom cell with a transparent background and you can add those buttons on it. Alternatively, you could use the section footer to do pretty much the same.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.