iphoneiosuitableviewtable-footer

resize Footer in UItableview


I am adding the following codes to add a footer with a button to perform an action. i am not able to re-size the button to the size of the cell. The change in the CGRectMake(0, 0, 300,44) value is not affecting the change of the footer appears can any one help me. I am using a table having more session. i don't want a footer for every session instead i need at the end of the table so i inserted the following code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath   
*)indexPath 
{
//...
footerView  = [[UIView alloc] init];

UIButton* Logoutbutton = [UIButton buttonWithType:UIButtonTypeCustom];

[Logoutbutton setTitle:@"Logout" forState:UIControlStateNormal];

NSLog(@"cell width : %d",cell.contentView.frame.size.width);
[Logoutbutton setFrame:CGRectMake(0, 0, 300,44)];
[Logoutbutton setBackgroundImage:[UIImage imageNamed:@"LogoutBgImage.png"] 
forState:UIControlStateNormal];
[Logoutbutton setBackgroundColor:[UIColor clearColor]]; 

[Logoutbutton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
[Logoutbutton addTarget:self action:@selector(LogoutbuttonPressed:) 
forControlEvents:UIControlEventTouchUpInside];

Settingstable.tableFooterView = Logoutbutton;

return cell;
}

- (void)LogoutbuttonPressed: (UIButton*) button
{
 //some action
}

Can any one help me to fix this issue


Solution

  • use this way for footer of tableview

    self.tableView.tableFooterView = myCustomFooterView
    

    and for footer view of whole table,use

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

    and read more about it here

    http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html

    and if you wan't footer of only one cell, then implement a custom cell, and use layoutsubviews to change the cell settings, for custom cell use this link

    http://www.e-string.com/content/custom-uitableviewcells-interface-builder

    http://www.galloway.me.uk/tutorials/custom-uitableviewcell/

    http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html