How to programmatically add a simple default loading(progress) bar in iphone app

前端 未结 18 2592
你的背包
你的背包 2020-12-12 17:16

I am using http communication in My iPhone app. I want to show a progress bar while it is loading data from server. How can I do it programmatically?

I just want a d

18条回答
  •  没有蜡笔的小新
    2020-12-12 17:35

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    indicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
    indicator.center = self.view.center;    
    [self.view addSubview:indicator];
    [indicator bringSubviewToFront:self.view];
    [UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE;
    

    Write below code when you want to show indicator

    [indicator startAnimating];
    

    write below code when you want to hide indicator

    [indicator stopAnimating];
    

提交回复
热议问题