在UIViewController中获得Container View里的embed viewController的引用
2013-09-25 10:40
309 查看
When you want to use a controller you use the UIStoryboard method instantiateViewControllerWithIdentifier:, using the identifier that you give to the controller in IB,but this method will create a new instance of the UIViewController.
You can also use the performSegueWithIdentifier:sender: method (which also instantiated the view controller). You should check out the "Using View Controllers in Your App" section in the Apple docs. It also makes reference to the fact that child view controllers are instantiated at the same time as the container controller.
After edit: If you embed a container view in another view controller, that embedded view's controller can be referenced from the containing controller with self.childViewControllers (which will be an array, so if there is just one, you can get it with lastObject).
You can also use the performSegueWithIdentifier:sender: method (which also instantiated the view controller). You should check out the "Using View Controllers in Your App" section in the Apple docs. It also makes reference to the fact that child view controllers are instantiated at the same time as the container controller.
- (void) prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender { // -- Master View Controller if ([segue.identifier isEqualToString:@"embedViewController1"]) { self.frontViewController = segue.destinationViewController; self.frontViewController.delegate = self; NSLog(@"front segue %d",self.frontViewController.sliderButton.tag); // ... } // -- Detail View Controller else if ([segue.identifier isEqualToString:@"embedViewController2"]) { self.backViewController = segue.destinationViewController; // ... NSLog(@"back segue"); } }
After edit: If you embed a container view in another view controller, that embedded view's controller can be referenced from the containing controller with self.childViewControllers (which will be an array, so if there is just one, you can get it with lastObject).
相关文章推荐
- 获得UIView对应 的viewController
- iOS获得view对应的UIViewController
- UIViewController的 dismissViewControllerAnimated:completion:方法
- xib和代码创建viewcontroller后在viewdidload里面获得的self.view的大小问题
- Container View Controller
- iOS - 使用ZoomingViewController来放大UIView至全屏
- 使用XIB自定义一个UIView,然后将这个view添加到controller的view
- UIViewController view视图的加载
- iOS中Container View Controller的使用
- View=android.widget.ZoomButtonsController$Container not attached to window manager
- UIview获得Controller
- UIViewController remove subview
- RCP中获得其他view或editor引用的方法
- iOS 容器控制器 (Container View Controller)
- 如何让你的UINavigationController.rootViewController 占领这个屏幕?UINavigationController UIView fullScreen
- iOS的webViewcontroller中获得链接进行下载
- Sizing views inside a container view controller
- view在UIViewController中的生命周期
- UIViewController+UITableView 和 UITableViewController
- Custom Container View Controller容器vc