2016-04-25 54 views
1

如何禁止用戶在下載該視圖的數據時與視圖控制器中的任何元素進行交互?在Swift中禁用ViewController

onStartParse() 
fetchUserInfo() 
onFinishedParse() 

我有這3種方法在我的viewDidLoad。該fetchUserInfo()是實際上從我的數據庫做的下載

+2

'controller.view.userInteractionEnabled = FALSE' – EmilioPelaez

+2

可能重複完全下載的方法[禁用屏幕上當前視圖的用戶交互](http://stackoverflow.com/questions/7878022/disabling-user-interaction-of-the-current-view-on-screen) –

+0

您可以將'userInteractionEnabled'設置爲'虛擬「當你統計下載。下載結束後,將'userInteractionEnabled'設置回'true'。如果您想要在整個應用中暫時禁用交互,請查看鏈接的副本。 – dasblinkenlight

回答

5

寫如下的功能上開始下載,並在迅速

func onStartDownloading(){ 
self.view.userInteractionEnabled = false 

} 

func onCompleteDownloading(){ 

self.view.userInteractionEnabled = true 
} 
+0

我試過這個,但按鈕仍然是可按下的,並導致他們各自的行動 –

+0

你有導航欄或TabBar按鈕,如果按鈕是超級視圖的一部分是可能的? –

+0

無論是在視圖還是在導航欄中,都不禁用UIElements –

相關問題