2016-08-25 68 views
-4
let VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("loadingViewController") as! loadingViewController 

如何在全球範圍內宣佈VC1,因此可以使用它不同的功能如何聲明視圖 - 控制全球

+0

在appDelegate中聲明它,就像var vc1:yourViewController! –

+1

你能提供更多關於你想要實現的細節嗎?你不應該需要一個全局變量 – Paulw11

回答

2

這樣首先創建它(全球):

var VC1 = LoadingViewController() 

然後轉到您的視圖控制器和將其添加到viewDidLoad

VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("loadingViewController") as! loadingViewController 
+0

謝謝!這行得通! =) –