2014-08-28 113 views

回答

0

你可以這樣做

YourViewController *aView = [[YourViewController alloc] 
           initWithNibName:@"xibName" bundle:nil]; 
[self presentViewController:aView animated:YES completion:nil]; 
+0

我想從UIView.UIView加載UIViewController沒有presentViewController方法。 – Sofeda 2014-08-28 11:45:10

+0

比你可以這樣做[yourViewObject addSubview:aView.view]; – Rajesh 2014-08-28 11:48:42

+0

在這種情況下,只有UIViewController.view可見。我需要ViewController作爲rootviewController – Sofeda 2014-08-28 11:50:14

0

您可以使用NSNotification以通知的ViewController呈現另一個視圖控制器。

點擊此處瞭解詳情:

NSNotificationCenter Class Reference

顯示的視圖控制器具有:

ViewController *viewController = ...; 

[self presentViewController:viewController animated:YES completion:NULL]; 

另一種選擇是,從你的按鈕調用委託。

+0

我想從UIView.UIView加載UIViewController沒有presentViewController方法。 – Sofeda 2014-08-28 11:44:53

+1

是的,你應該通知帶有NSNotification/Delegate的ViewController來呈現你的控制器。 – Matz 2014-08-28 12:14:40

+0

你是對的@Matz – Sofeda 2014-08-31 07:06:35