【问题标题】:Load View controller in xib file在 xib 文件中加载视图控制器
【发布时间】:2015-02-26 17:37:46
【问题描述】:

我想知道是否可以在 Xib 文件中的这两个视图之间进行某种分隔。

主视图被加载到情节提要的滚动视图中。 .

(所以如果我点击 Bewerken(edit) 我会被推送到右侧的视图控制器)

谢谢!

【问题讨论】:

  • 为什么使用单独的xib文件而不是storyboard?
  • 取决于您所说的“某种转场”是什么意思。转场是故事板的东西;如果没有故事板中涉及的两个控制器,您将无法拥有一个。不过,您可以手动推送或展示该控制器。
  • 此 Xib 中“主”视图的内容嵌入在故事板文件中的 UIscrollview 中。 @艾克
  • 在下面查看我的反馈作为答案。我建议切换到带有嵌入式转场的情节提要。

标签: ios objective-c uiviewcontroller segue xib


【解决方案1】:

我建议将其更改为情节提要内的容器视图,而不是单独的 Xib。您可以将 UIContainerView 添加和定位/调整大小作为子视图,并添加一个“Storyboard Embed Segue 以附加另一个 ViewController。这就是它在 IB/Storyboard 中的样子:

在运行时,蓝色的 UIView(或嵌入的 UIViewController,如果你喜欢)将作为子视图嵌入到宿主 UIView 中:

如果您将实现更改为这样,您将进入美丽的 segue 世界,您可以在其中拖放 segue :)

【讨论】:

    【解决方案2】:

    你可以做两件事:

    1 - 将主视图包装在导航控制器中,以便您可以执行以下操作:

    @IBAction func loadEditController(sender:UIButton){
    
        let editController = RegisterController(nibName:"RegisterXIB", bundle:nil)
    
        navigationController?.pushViewController(editController, animated: true)
    
    }
    

    2 - 在当前上下文上显示编辑控制器并自己制作动画

       @IBAction func loadEditController(sender:UIButton){
    
        let editController = RegisterController(nibName:"RegisterXIB", bundle:nil)
        editController.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
    
        presentViewController(editController, animated: false, completion: nil)
    
        //Move it offscreen and the animate it here
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-19
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      • 2016-11-26
      • 2015-03-24
      相关资源
      最近更新 更多