【问题标题】:add CollectionViewController as subview of another ViewController添加 CollectionViewController 作为另一个 ViewController 的子视图
【发布时间】:2014-09-23 08:03:59
【问题描述】:

如何在ViewController 中实例化CollectionViewController 并将CollectionViewControllers 视图设置为ViewController 的子视图? FlowLayout 有一个问题,但我找不到解决方案。

我需要在 2 个单独的 viewControllers 中具有相同 collectionView 的功能。因此,我想创建CollectionViewController,我可以使用不同的属性重复使用它,并将其视图分配给第二个ViewController

【问题讨论】:

    标签: ios objective-c iphone uiviewcontroller uicollectionview


    【解决方案1】:

    我不确定您是否已经尝试过,因为您没有真正放置任何代码示例或详细解释您的问题到底是什么,但您可以将 collectionViewController 作为 childViewController 添加到您的 parentViewController。

    yourCollectionViewController *yourName = [self.storyboard instantiateViewControllerWithIdentifier:@"YOUR_IDENTIFIER"];
    
    //Add view to the container view tower
    
    [self addChildViewController:yourName];
    [self.view addSubview:yourName.view];
    [yourName didMoveToParentViewController:self];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 1970-01-01
      • 2014-01-20
      相关资源
      最近更新 更多