How do I show two or more buttons in a UITableViewsFooter section?
I am creating an application on my home screen. On this main screen, I have a button called "continue".
Now I want to load a new view using this button. I did it successfully. On this new view, I have a UITable and a navigation bar. Now I want 2 or 3 buttons below the View table.
I am not creating a custom cell. I want to do it through the footer and load new views from those buttons.
Also I created a Custombutton which I replace like this cell: accessaryView = mycustombutton
but I want to set the button at the very end of the cell. There is some space left in the cell. How to create a square button that hides the accessaryView completely and the button ends where the tablecell ends.
a source to share
There is a way in the TableView to return the table / section footer view instead of plain text.
You can implement this method and create your own view with two buttons. Then return the view.
These are the methods you should look for when creating a footer for a section
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
And this is the tableView property to create the footer for the whole table
@property(nonatomic, retain) UIView *tableFooterView
[tableView setTableFooterView:yourViewWithBtns];
As for the accessory, by default the created accessory will leave some space at the end, even when using custom accessories. The alternative is to add a custom button to the cell content view rather than setting it as an accessory
yourButton.frame = CGRectMake(260.0, 10.0, 40.0, 20.0);
[cell.contentview addSubview:yourButton];
But this will create problems if you allow editable cells (you have to either reposition the button when editing the table, or hide it), which is automatically handled for you by accessorizing)
a source to share
As I understand it, you are asking two questions here. (You might want to clear up your question a bit.)
For the first: you can change the property of the UITableView tableFooterView
as a custom UIView to which you add two or three UIButtons. For example, if you had a footer view with buttons fView
and your table view was called tview
:
tview.tableFooterView = fview;
For the second one: you need to create your own UIView with a custom frame, set it to the UITableViewCell accessoryView
, and then add your button to that view, not the accessory. To do this, use the UIView method initWithFrame:
.
a source to share