Activity indicator (spinner) with UIActivityIndicatorView

前端 未结 4 538
耶瑟儿~
耶瑟儿~ 2021-02-04 21:32

I have a tableView that loads an XML feed as follows:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if ([stories count] == 0) {         


        
4条回答
  •  你的背包
    2021-02-04 21:56

    Starting a new thread can be overkilling and a source of complexity if you want to do things that are supposed to start on the main thread.

    In my own code, I need to start a MailComposer by pushing a button but it can take some time to appear and I want to make sure the UIActivityIndicator is spinning meanwhile.

    This is what I do :

    -(void)submit_Clicked:(id)event { [self.spinner startAnimating]; [self performSelector:@selector(displayComposerSheet) withObject:nil afterDelay:0]; }

    It will queue displayComposerSheet instead of executing it straight away. Enough for the spinner to start animating !

提交回复
热议问题