Thursday, 29 August 2013

Activate View for header delegate for specific section in single table

Activate View for header delegate for specific section in single table

I am developing an application in which I need header to customize and add
my own button just for single section. I googled and done some code where
I am able to add button, but I am facing two issue.
Titles of other's section is not showing.
Button not show properly because of tableview scroll size same after
adding button. Here is what I am doing.
(UIView *) tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section{
UIView * headerView = [[[UIView alloc] initWithFrame:CGRectMake(1, 0,
tableView.bounds.size.width, 40)] autorelease]; [headerView
setBackgroundColor:[UIColor clearColor]]; if(section==2){ float width =
tableView.bounds.size.width; int fontSize = 18; int padding = 10;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(padding, 2,
width - padding, fontSize)]; label.text = @"Texto"; label.backgroundColor
= [UIColor clearColor]; label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor darkGrayColor]; label.shadowOffset =
CGSizeMake(0,1); label.font = [UIFont boldSystemFontOfSize:fontSize];
[headerView addSubview:label];
UIButton * registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[registerButton setImage:[UIImage imageNamed:@"P_register_btn.png"]
forState:UIControlStateNormal]; [registerButton setFrame:CGRectMake(0, 0,
320, 150)]; [headerView addSubview:registerButton];
return headerView; } return headerView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 3;
}
(NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section{ if(section==0) return
@"Registration"; else if(section==1) return @"Player Detail"; return nil;
}
Here is Image of my out put in which Texto text show but button is under
that area where the end limit of table view scroll height and also section
0 and 1 title is not showing I also block code for first and second
section in viewforheaderinsection. Thanks in advance.

No comments:

Post a Comment