Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
765 views
in Technique[技术] by (71.8m points)

swift - Segue from a SLPagingViewSwift VC and dismiss the destination VC to return

***** You can download this project to see the issue *****

I've embedded SLPagingViewSwift in my project. In the third VC i added a button (and a table):

enter image description here

The button configured to do a segue (Present Modally):

enter image description here

In the target VC i have a button (marked in square green above) that do:

 @IBAction func dissmissIt(_ sender: AnyObject) {

    dismiss(animated: true, completion: nil)
}

But after the target VC is dismissed i see the button in the third VC in a different location (higher):

enter image description here

The layout is configured, button 40 pixels from the top (and table 8 pixels from the button):

enter image description here

What went wrong?

I guess the initial layout configuration takes the SLPagingViewSwift navigation bar into consideration but after the dismiss it recalculates the layout from the top of the screen.

What is the right way to perform the segue and dismiss the target VC while keeping the layout as designed?

I saw this answer

But i was not sure where to use it. i tried:

nav?.view.translatesAutoresizingMaskIntoConstraints = false

and

controller.view.translatesAutoresizingMaskIntoConstraints = false

But with no luck.

***** You can download this project to see the issue *****

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem. After a lot of hour trying to fix it, I found the solution.

  1. Click on your segue
  2. On the right panel click on 'Show the attributes inspector'
  3. Set the Presentation option to 'Over Full Screen'.

Worked for me. I hope it works for you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...