How can i add a activity indicator below the UITableView?

后端 未结 4 1524
自闭症患者
自闭症患者 2020-12-28 17:22

In my application i want to add activity indicator under UItableview where tableview will scroll but i do not know how can i add activity indicator over there.

To el

4条回答
  •  青春惊慌失措
    2020-12-28 18:01

    The best way to add activity indicator is at footer of tableview.

        - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
    UIView *headerView = [[[UIView alloc] init]autorelease];
    
        [headerView setBackgroundColor:[UIColor clearColor]];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self 
               action:@selector(aMethod:)
     forControlEvents:UIControlEventTouchDown];
    [button setTitle:@"Load More" forState:UIControlStateNormal];
    button.frame = CGRectMake(10.0, 210.0, 160.0, 40.0);
    
    
        [headerView addSubview:button];
    
        [headerLabel release];
    
        return headerView;
    
    }  
    

    Add a button to the footerView and set action to button (as you needed). This how app store tableview works. On clicking button fetch some more data add to table array scroll the table without animation.

提交回复
热议问题