views:

459

answers:

2

hello i am creating a aplication in i have a home screen.on that home screen i have button titled continue. now i want to load a new view with that button's click.i had successfully done this. on that new view i have a UITable,a navigation bar,now i want 2 or 3 buttons beneath the table View. i do not to create custom cell. i want to done this through footer view and load new views from that buttons.

also i have created a Custombutton which i replace like this cell.accessaryView = mycustombutton. but i want to set the button at the very end of cell.there is some space left behind in the cell.how do craete a square button which hides the accessaryView completely and the button ends where tablecell ends.

+1  A: 

As I understand it, you're asking two questions here. (You might want to clean up your question a bit.)

For the first: you can change the UITableView's property tableFooterView to be a custom UIView to which you add your 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: You'll have to create your own UIView with a custom frame, set it to the UITableViewCell's accessoryView, then add your button to that view rather than to the accessory view. Use UIView's initWithFrame: method to do this.

Tim
+1  A: 

The TableView has a method to return the view for the footer of a table/section instead of plain text.

You could implement this method and create your own view with 2 buttons. Then return the view.

These are the methods you should be looking at implementing for creating a footer for a section

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

And this property of tableView for creating a footer for the whole table

@property(nonatomic, retain) UIView *tableFooterView

[tableView setTableFooterView:yourViewWithBtns];

As for the accessory, by default an accessory created will leave some space at the end, even when using custom accessories. An alternative is to add the custom button to the cell's content view instead of 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 will have to either change the button's position when table is editing or hide it - which is automatically handled for you with an accessory view)

lostInTransit