E
E
Emil2021-05-24 01:33:08
Swift
Emil, 2021-05-24 01:33:08

How to open a View controller with content on top of an already opened one?

Greetings, there are such ViewControllers.
60aad79d45f03145697201.png
When you click on a certain button, it moves to another view controller.
I'm interested in how you can avoid switching to another controller, but simply display key content, such as an input field, some kind of background image, but on the same controller on which the button is located?
I found information about child view, but I get an error.
60aad81aca539905803497.png
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vorobei, 2021-05-24
@ivanvorobei

If you have two controllers and want to add one to the other, then you need to add the second controller's view to the parent's view . And hold the attendant calls of adding the controller as a child.

addChild(child)
child.view.frame = frame
view.addSubview(child.view)
child.didMove(toParent: self)

You do the layout as for ordinary views.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question