[問題] tabBarView delegate 傳值

看板MacDev作者 (Unknown)時間11年前 (2013/10/28 17:00), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/1
如果現在有一個 tabBarViewController 內含了 View A 和 View B 我想在 使用者點選 View B , View A viewDidDisappear 時將值傳給View B 我用StoryBoard , 並在ViewB的StoryBoardID 設定為 ViewB, 之後我先宣告了一個 protocol 在 B.m中進行實作 - (void)passValueMethod:(NSString *)string { self.Label.text = string; } 在A.h 中 property(assign, nonatomic) id<passValue> delegate; 在A.m 中 ViewDidDisappear 時 ViewB *B = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewB"]; A.delegate = B; [A.delegate passValueMethod:@"John"]; 可是並沒有正確取得 ViewB 的指針, 所以Label也沒有改變 請問該怎麼做才是正確的呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.251.44.30

10/28 21:51, , 1F
ViewB *B = ... 錯了。
10/28 21:51, 1F

10/28 21:53, , 2F
instantiateVC W/ ID 是alloc並且init一個全新的VC
10/28 21:53, 2F

10/28 21:53, , 3F
應該透過 tabBarViewController 取得你要的viewB
10/28 21:53, 3F
文章代碼(AID): #1IRYUQGk (MacDev)
文章代碼(AID): #1IRYUQGk (MacDev)