在Swift中禁用ViewController
问题描述:
如何禁止用户在下载该视图的数据时与视图控制器中的任何元素进行交互?在Swift中禁用ViewController
onStartParse()
fetchUserInfo()
onFinishedParse()
我有这3种方法在我的viewDidLoad
。该fetchUserInfo()
是实际上从我的数据库做的下载
答
写如下的功能上开始下载,并在迅速
func onStartDownloading(){
self.view.userInteractionEnabled = false
}
func onCompleteDownloading(){
self.view.userInteractionEnabled = true
}
+0
我试过这个,但按钮仍然是可按下的,并导致他们各自的行动 –
+0
你有导航栏或TabBar按钮,如果按钮是超级视图的一部分是可能的? –
+0
无论是在视图还是在导航栏中,都不禁用UIElements –
'controller.view.userInteractionEnabled = FALSE' – EmilioPelaez
可能重复完全下载的方法[禁用屏幕上当前视图的用户交互](http://stackoverflow.com/questions/7878022/disabling-user-interaction-of-the-current-view-on-screen) –
您可以将'userInteractionEnabled'设置为'虚拟“当你统计下载。下载结束后,将'userInteractionEnabled'设置回'true'。如果您想要在整个应用中暂时禁用交互,请查看链接的副本。 – dasblinkenlight