2016-10-11 49 views
0

我想從一個視圖,充滿數據從一個對象,到相同的視圖,但通過segue填充不同的對象。如何繼續使用我所在的UIViewController?

使用segue是非常必要的,因爲我們用戶需要在切換對象和刷新視圖時能夠返回到過去的視圖控制器。

例子: (ThisView,用的thisObject填充視圖) - >(ThisView,與thisOtherObject填充視圖)

我已經試過什麼:

presentView控制器:這並沒有因爲工作這不是我想要實現的默認搜索。

let next: NewClubProfile = storyboard?.instantiateViewControllerWithIdentifier("clubProfile") as! NewClubProfile 
presentViewController(next, animated: true, completion: nil) 

使用導航控制器:無法弄清楚如何Segue公司新的對象來填充其他視圖

let next: NewClubProfile = storyboard?.instantiateViewControllerWithIdentifier("clubProfile") as! NewClubProfile 
self.navigationController?.pushViewController(next, animated:true) 
+0

在做第二種方法時你面臨什麼問題? –

+0

第二種方法實際上是行得通的,我還在弄清楚如何將新對象添加到視圖控制器。如果你看看我在下面發佈的答案,你可以看到工作代碼。 – thoseguysintown

回答

0

應該採取再發布此之前解決這個自己,但我做不到找到適合我需要的答案。無論如何,解決它,這是什麼對我有用。

let next: ViewController = storyboard?.instantiateViewControllerWithIdentifier("viewName") as! ViewController 
next.object = newObject 
self.navigationController?.pushViewController(next, animated:true)