Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't allow user interaction when activity indicator view is visible

Tags:

I have a view which contains two views. One of those views contains two buttons and some text labels. The other one, with alpha set to 0.25, has an UIActivityIndicatorView to tell the user that the app is working and he must wait until it finishes. If the user touch a button while the UIActivityIndicatorView is spinning, when the UIActivityIndicatorView stops, the app remember the user action and responds to it. How can I discard the user interaction that occur while the UIActivityIndicatorView is spinning?

Thanks for reading.

P.D.: Like is commented in this thread, I prefer do not to use any modal solution.

EDITED:

I am currently using this code and it does not work right.

- (void)viewDidAppear:(BOOL)animated {    // The view appears with an UIActivityIndicatorView spinning.   [self showResults]; // The method that takes a long time to finish.   [self.activityIndicator stopAnimating];   // When the showResults method ends, the view shows the buttons to the user.   [self.activityIndicatorView setHidden:YES];   [self.menuButton setEnabled:YES];   [self.menuButton setUserInteractionEnabled:YES];   [self.playButton setEnabled:YES];   [self.playButton setUserInteractionEnabled:YES];   [self.view setUserInteractionEnabled:YES];   [self.interactionView setUserInteractionEnabled:YES]; } 
like image 790
Daniel García Baena Avatar asked Apr 05 '11 11:04

Daniel García Baena


1 Answers

I found these methods very useful:

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];  [[UIApplication sharedApplication] endIgnoringInteractionEvents]; 
like image 154
ppalancica Avatar answered Nov 07 '22 11:11

ppalancica