简体   繁体   中英

Presenting view controller over current context storyboard

I have been trying to solve this for a while with a variety of people suggesting several different ways to achieve this and none of them working for me.

I am trying to display a view controller over the current context with a clear background. However each time I perform the segue the view controller underneath is removed from the view hierarchy.

Here is the presenting view controller. 呈现视图控制器

And here is the current state when presenting the view modally. 模态弹出

As the segue is taking place the modal has the correct transparency effect however when the segue completes the background turns black indicating the view controller has been removed from the hierarchy.

Now many suggestions focus on setting up the modal in code however all these settings are available in the storyboard and I prefer to leave things like that in there. As suggested here I have setup my view controllers like this however I still have the above effect.

Here is my storyboard setup.

Presenting view controller settings 呈现视图控制器设置

Segue settings Segue设置

Modal view controller settings 模态视图控制器设置

Any help would be much appreciated.

you can make those view controllers child of the VC you want to present them on here , by making one view controller child of another, you can add view of child VC as a subview to the view of parent VC

you can then play with transparency/color of child VC view's

This can also be helpful tutorial

presenting view controller on top of the current one won't work for you, you will have add other view controller as child for the current one and then add it's view as subview to the current VC's view. then if you clear background color for child VC's view it will appear transparent and show you previous VC's view in background

Edit: you can achieve the same effect using presentation controller here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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