简体   繁体   中英

Created Table Cell With UIView as subview Not Displaying in iOS7

I have created UIView on top of the UITable Cell but its not displaying in iOS7 which is working fine in iOS6. Kindly provide me the solution.

We are adding the More button @ the end of the table.

Added code for the same:

UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 768, 40)];
footerView.backgroundColor  = [UIColor grayColor];
UIButton *btnLoadMore = [UIButton buttonWithType:UIButtonTypeCustom];
btnLoadMore.frame = CGRectMake(-10, 0, 768, 30);
btnLoadMore.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
[btnLoadMore setTitle:@"Sample" forState:UIControlStateNormal];
[btnLoadMore setBackgroundColor:[UIColor redColor]];
[btnLoadMore setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btnLoadMore addTarget:self action:@selector(loadMore) forControlEvents:UIControlEventTouchUpInside];
btnLoadMore.userInteractionEnabled=YES;
[btnLoadMore.titleLabel setFont:[UIFont fontWithName:@"Helvetica" size:17.0]];
[footerView addSubview:btnLoadMore];
 [footerView setHidden:YES];
[footerView setTag:999];
[cell addSubview: footerView];
for (id subView in [cell subviews]) {
        [subView setHidden:NO];
       }
    UIView *lastRow = [cell viewWithTag:999];
    [lastRow setHidden:YES];

    if(indexPath.section == [arSearch count] && isLoadMore){
        for (id subView in [cell subviews]) {
            [subView setHidden:YES];
        }
        cell.backgroundView = nil;
        [lastRow setHidden:NO];

Check your code. Why you have written following line :

     [footerView setHidden:YES];

I think you are hiding view from cell.

Instead of

[cell addSubview: footerView];

use

[cell.contentView addSubview: footerView];

Also remove

[footerView setHidden:YES];

For loadmore, I always do below.

UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 65)];
v.backgroundColor = [UIColor clearColor];

    int mySiz = 0;
    // keep counter how many times load more is pressed.. initial is 0 (this is like index)
    mySiz = [startNumberLabel.text intValue]+1;

    // i have 15 bcz my index size is 15.
if ([feeds count]>=(15*mySiz)) {
    NSLog(@"showing button...");
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(10, 10, 296, 45)];
    [button setBackgroundImage:[UIImage imageNamed:localize(@"loadmore")] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(loadMoreData:) forControlEvents:UIControlEventTouchUpInside];
    [v addSubview:button];
    mainTableView.tableFooterView = v;
} else {
    mainTableView.tableFooterView = nil;
}
}

[mainTableView reloadData];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM