Block interface until operation is done

人走茶凉 提交于 2019-12-12 02:52:39

问题


I have a login method that connects to a server to check the user info when the user clicks on the login button.

How can i block the view showing an activity indicator so that the user does not click on the button again?


回答1:


Why don't you just set the userInteractionEnabled to false for the button?

btn.userInteractionEnabled = NO;

and set it back to YES after the login is completed?

You can set this property to every responsive UI element in the view you wish to disable.

BTW

This off-curse dose not prevent you from showing an activity indicator.

As always I love to recommend MBProgressHUD

EDIT If you are getting ARC errors do this:

  1. Select your target
  2. Look for the MBProgressHud.m file in the "Build Phases" -> "Compile Sources"
  3. add -fno-objc-arc in the Compiler Flags of the MBProgressHud.m file.

This will flash xCode not to compile this file with ARC.



来源:https://stackoverflow.com/questions/8628981/block-interface-until-operation-is-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!