IOS: ActivityIndicator over UITableView… How to?

后端 未结 5 1469
广开言路
广开言路 2020-12-31 03:19

i want display an activity indicator over a uitableview while it\'s loading data (in another thread). So in the ViewDidLoad method of the UITableViewController:



        
5条回答
  •  猫巷女王i
    2020-12-31 03:43

    [IOS 8+] The above does not work for me. Instead I store the indicator view (ac) in the class. Then I do:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (ac.isAnimating)
            return 50.0f;
        return 0.0f;
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        if (ac.isAnimating)
            return ac;
        return nil;
    }
    

    For showing the indicatorview I do

    [ac startAnimating]
    

    For hiding it, I do

    [ac stopAnimating]
    

提交回复
热议问题