From your video, I noticed that your UIImageView always “modified” at the top, not at the bottom. This is certainly related to your autodetection restriction, which you call the "Top Space to Top Layout Guide". As long as your UIImageView view UIImageView goes through your scroll view controller, it doesn't know where the top layout is, so its topLayoutGuide.length is 0 . Only after the animation is complete, the view controller receives a positive value for topLayoutGuide.length . Yes, the pageview controller should be a little smarter than that, but it is not. You can either stop using the top layout guide, or restrict autodetection to the top of your supervisor. Or you can continue to use the top layout, but consider when its length is 0 . You can do this by creating an output for your NSLayoutConstraint storyboard and overriding viewWillLayoutSubviews() in the ViewController containing your UIImageView s:
@IBOutlet weak var topSpaceToTLG: NSLayoutConstraint! var parentTLGlength: CGFloat = 20 override func viewWillLayoutSubviews() { if self.topLayoutGuide.length == 0 {
This will always put the top of your UIImageView in the top layout guide, assuming the status bar is always 20 points. Before laying out the subheadings, he checks whether the length of the top layout is 0 or not, and adjusts the auto-detection limit accordingly. After the transition animation is completed, the layout starts again, and the upper length of the layout guide is expected, so the constraint constant may return to 0 . Even better than hardcoding, the value is to convey in the parent view the exact length of the controller during initialization, given any possible changes to the start guide, such as adding a navigation bar.
Christopher Whidden Jan 13 '15 at 6:10 2015-01-13 06:10
source share