zoukankan      html  css  js  c++  java
  • 在UIViewController中获得Container View里的embed viewController的引用

    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.

    - (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).

  • 相关阅读:
    iOS:不同属性声明方式的解析
    iOS:图像和点击事件
    iOS:NAV+TABLE结合
    iOS:实现表格填充和选择操作
    iOS: 填充数据表格
    iOS:导航栏的工具条和导航条
    iOS:使用导航栏
    hello,world不使用ARC
    iOS代码实现:创建按钮,绑定按钮事件,读取控件值
    iOS版 hello,world版本2
  • 原文地址:https://www.cnblogs.com/fengjian/p/3338263.html
Copyright © 2011-2022 走看看