简体   繁体   English

在xib文件中加载View控制器

[英]Load View controller in xib file

I was wondering if i could make some sort of a segue between these 2 views in a Xib file. 我想知道是否可以在Xib文件的这两个视图之间进行某种区分。

the main View is loaded into a scrollview in the storyboard. 主视图将加载到情节提要中的滚动视图中。 在此处输入图片说明 .

(so if ik click Bewerken(edit) i would get pushed to the view controller on the right) (因此,如果我点击Bewerken(edit),我将被推送到右侧的视图控制器)

Thanks! 谢谢!

I would suggest changing this to a Container View inside the storyboard instead of a separated Xib. 我建议将其更改为情节提要中的容器视图,而不是单独的Xib。 You can add and position/size UIContainerView as a subview and add a" Storyboard Embed Segue to attach another ViewController. This is what it will look like in IB/Storyboard: 您可以添加UIContainerView并将其定位/调整为子视图,并添加“ Storyboard Embed Segue来附加另一个ViewController。这就是IB / Storyboard中的样子: 在此处输入图片说明

During runtime, the blue UIView (or the embedded UIViewController if you like) will be embedded in the hosting UIView as a subview: 在运行时,蓝色的UIView(或嵌入式UIViewController,如果需要的话)将作为子视图嵌入到托管UIView中:

在此处输入图片说明

If you change your implementation to this, you are in the beautiful segue world where you can just drag-and-drop segues :) 如果您将实现更改为此,则您将身处美丽的segue世界中,只需拖放即可:)

You could do 2 things: 您可以做两件事:

1 - Wrap the main view in a Navigation Controller so you can do the following: 1-在导航控制器中包装主视图,因此您可以执行以下操作:

@IBAction func loadEditController(sender:UIButton){

    let editController = RegisterController(nibName:"RegisterXIB", bundle:nil)

    navigationController?.pushViewController(editController, animated: true)

}

2 - Present the Edit Controller over the current context and animate it yourself 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


}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM