I want to use addChildViewController
in View
(one view fro subviews array) but I don't know about that. this is my code :
for (UIView *subview in self.view.subviews) {
if (subview.tag == 1) {
CartView *cart = [[CartView alloc]init];
[cart willMoveToParentViewController:????];/* (UIViewController*) from subview*/
[cart.view setFrame:CGRectMake(0.0f,CGRectGetHeight(self.view.frame),CGRectGetWidth(self.view.frame),CGRectGetHeight(self.view.frame))];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
[cart.view setFrame:CGRectMake(0.0f,0,CGRectGetWidth(self.view.frame),CGRectGetHeight(self.view.frame))];
[UIView commitAnimations];
[subview addSubview:cart.view];
[???? addChildViewController:cart];
[cart didMoveToParentViewController:????];
}
}
I don't know how to get UIViewController* from subview!!!!
From Apple's Documentation :
(Here content is considered as child controller)
Adding another view controller’s view to the container’s view hierarchy
Here’s what the code does:
So ,in your case you are trying to add ViewController to your view which doesn't work. The
CartView
should be aUIViewController
notUIView