0

這是我的代碼:如何在使用swrevealviewcontroller時將數據從oneviewcontroller傳遞到anotherviewcontroller?

let swswipe:SWRevealViewController=UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("swswipe") as! SWRevealViewController 
     if(indexPath.row==0) 
     { 

      let swipe=swipeView() 
      swipe.collectionClick="one" 
      self.presentViewController(swswipe, animated: true, completion: nil) 

     } 



      front 
       | 
1st view <->swreveal<->2ndview(swipe) 

我試圖發送的值從1日至2日,但中間有一個swrevealview控制器的出現,讓價值沒有得到

,但我沒有得到了什麼

print("coming to collection view", self.collectionClick) 
+0

你試過委託模式嗎? – Smile

+0

不,我沒有嘗試委託模式,你可以簡要解釋我請@ismail –

+0

但我使用集合視圖,而單擊我需要發送字符串的單元格... @ ismail –

回答

0

您可以在任何的下列方式做到這一點:

  • 當第二個控制器離開並讓父母監聽時發送通知。

  • 創建委託協議,讓第二個控制器直接引用父方法。

  • (如果需要通過後退按鈕操作實現)使用父窗口的viewWillAppear:並檢查isMovingToParentViewController屬性是否只是重新顯示。

並應用最適合您的值傳遞條件和值的可用性。

相關問題