2014-10-08 49 views
0

我有一個的UIViewController與黑色背景顏色和我這樣做:負載的UIViewController

CredenciaisViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"Credencial"]; 
    [_viewContainer addSubview:obj.view]; 
    _viewContainer.alpha = 1; 

CredenciaisViewController有紅色的背景顏色,但當它加載一半我的背景是白色的。

而UiButtons在白色部分時也不起作用。

爲什麼會發生這種情況? 而我該如何解決它?

+0

你爲什麼要這樣做: [_viewContainer addSubview:obj.view]; ??? – Atrash 2014-10-08 12:53:36

+0

因爲我需要在UIView中加載UIViewController。我在我的應用程序上有一些動畫,這些內容需要加載到這個UIView中。 有沒有其他方法可以做到這一點? – Shumi 2014-10-08 13:10:08

+0

我看到有人將UIView添加到UIViewController但是相反!即使您有一些動畫要做,也可以使用 ! 您是否需要將ViewController作爲對話框顯示? – Atrash 2014-10-08 13:13:01

回答

0

現在我明白了!
我把Container View

而在我的行動按鈕我所做的:

- (IBAction)mostrarCredenciais:(id)sender { 
CredenciaisViewController *credenciaisView = [self.storyboard instantiateViewControllerWithIdentifier:@"Credencial"]; 

[self addChildViewController:credenciaisView]; 
[credenciaisView didMoveToParentViewController:self]; 
credenciaisView.view.frame = self.containerView.bounds; 
[self.containerView addSubview:credenciaisView.view]; 
} 

然後運行良好!