Monday, 22 June 2015

In TableView, Add Footer and Remove Insets for iOS

Remove the Selection Index from Tableview
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%d", indexPath.row);
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}


Footer for Tableview
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,tableView.frame.size.width, 1)];
    [footerView setBackgroundColor:[UIColor lightGrayColor]];
    return footerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}


Remove Insets Spaces in Tableview for iOS 8
-(void)viewDidLayoutSubviews
{
    // iOS 8 separator inset 0
    if ([Table_View respondsToSelector:@selector(setLayoutMargins:)])
    {
        [Table_View setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell1 forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // iOS 8 separator inset 0
    
    if ([cell1 respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell1 setLayoutMargins:UIEdgeInsetsZero];
    }

}

No comments: