Best way to disable UIViewController interaction a

2019-06-07 18:16发布

Question says it all.

Is there a best recipe to follow to disable user interaction and show a activity indicator while fetching data from a web service or loading data from a core data fetch operation?

I'm using ASIHTTPRequest, JSONKit and Core Data in my particular app so any sample code using those Apis would be preferred.

Thanks - wg

3条回答
ら.Afraid
2楼-- · 2019-06-07 18:26

Create a UIView with transparent background and that takes the whole screen.

It will intercept the interaction and won't let the user tap on the other items on the screen.

Then you can add an UIActivityIndicator (and even a UILabel) as a subview of this transparent fullscreen view or whatever you need.

Note that there are multiple existing projects like SVProgressHUD that do that already too and that I strongly recommand.

查看更多
聊天终结者
3楼-- · 2019-06-07 18:44

A very very simple and easy way to accomplish both tasks is using MBProgressHUD.

Check it's repository in Github

Example usage:

+ (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;

+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated;

These two class methods will show/hide a simple activity indicator with a translucid background. It also has properties to show text, progress and a good delegate.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-06-07 18:44

Use the up mentioned HUD control on rootViewContoller. It will not let user to interact with UI.

查看更多
登录 后发表回答