Hi i am trying to set image for Background of Grouped Table-view Section's (Not for Section Header) i am using following code:-
-(void)addBackgroundViewForSectionIndex:(int)tagIndex {
for (UIView * subview in tbl_home.subviews) {
if(subview.tag == tagIndex)
[subview removeFromSuperview];
}
CGRect sectionFrame = [tbl_home rectForSection:tagIndex];
UIImageView *newView = [[UIImageView alloc]initWithFrame:sectionFrame];
newView.tag = tagIndex;
[newView setImage:[UIImage imageNamed:@"[email protected]"]];
[tbl_home addSubview:newView];
[tbl_home sendSubviewToBack:newView];
}
That set Image as a background but there is problem some cell is not display or newView
over some cell.
i would like to set image like the below screenshot:-
After some change now help with this code i successfully set the image as above image using this code:-
-(void)addBackgroundViewForSectionIndex:(int)tagIndex {
for (UIView * subview in tbl_home.subviews) {
if(subview.tag == tagIndex)
[subview removeFromSuperview];
}
CGRect sectionFrame = [tbl_home rectForSection:tagIndex];
UIImageView *newView = [[UIImageView alloc]initWithFrame:sectionFrame];
newView.tag = tagIndex;
[newView setImage:[UIImage imageNamed:@"[email protected]"]];
[tbl_home addSubview:newView];
[tbl_home sendSubviewToBack:newView];
}
previouselly i call this method in to cellForRowIndex
so that called every time and create problem. Now i call this method in
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
like bellow and working fine now:-
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[self addBackgroundViewForSectionIndex:indexPath.section];
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments