我有一個WatchKit應用程序,它用來自NSUserDefaults
的數據更新一些標籤。這些defaults
由iOS App中的兩個不同ViewControllers
更新。 如果我按下ViewController1
中的按鈕,則iOS App中的視圖以及WatchKit App中的視圖會更新(使用NSTimer每秒更新一次)。目前爲止這麼好,但現在我只需要在iOS Apps ViewController2
更新的手錶上顯示defaults
值。我想留在ViewController1
的視圖中,但是當我按下按鈕時,它應該是'運行所有的東西'在ViewController2
(尤其是在所有控制器數學完成後更新具體的NSUserDefault
值),但不移動到它。使用performSegueWithIdentifier來獲取DestinationViewController的功能,但沒有顯示它
我已經嘗試功能ViewController1
中按鈕的ViewController2().viewDidLoad()
,但這會導致崩潰。也嘗試使用像here這樣的委託,然後從隱藏的標籤中獲取我的價值,但無法使其工作。
當我乾脆轉移到ViewController2
與self.performSegueWithIdentifier("moveToView2", sender: self)
一切運作良好(上觀看所有的標貼被更新),但我不想要移動到視圖2,我希望當按下按鈕留在視圖1,但得到的NSUserDefaults
首先從View2更新...