我有一个视图,其中包含两个视图。其中一个视图包含两个按钮和一些文本标签。另一个设置为0.25,它有一个UIActivityIndicatorView来告诉用户应用程序正在工作,他必须等到它完成。如果用户在UIActivityIndicatorView旋转时点击一个按钮,当UIActivityIndicatorView停止时,应用程序会记住用户的动作并响应它。如何丢弃UIActivityIndicatorView正在旋转时发生的用户交互?
感谢您的阅读。
P.D.:就像这条线中的注释一样,我不喜欢使用任何模态解。
编辑:
我目前正在使用这段代码,它不能正常工作。
- (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];
}发布于 2013-05-17 12:41:34
我发现这些方法非常有用:
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];发布于 2017-01-31 10:12:41
在Swift 3.0中禁用交互:-
UIApplication.shared.beginIgnoringInteractionEvents()恢复互动:-
UIApplication.shared.endIgnoringInteractionEvents()发布于 2011-04-05 12:01:48
[_button setUserInteractionEnabled:NO];这应该禁用它,只要设置是当你想要用户点击它。
BOOL i_am_ready_to_submit = NO;
-(void)action_finished{
[self.activityIndicator stopAnimating];
i_am_ready_to_submit = YES;
}
-(IBAction)submit_button{
if(i_am_ready_to_submit){
[self submit];
}
}https://stackoverflow.com/questions/5551432
复制相似问题