Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create constraints for top layout guide and bottom layout guide #2

Closed
fatuhoku opened this issue Nov 3, 2014 · 9 comments
Closed
Assignees

Comments

@fatuhoku
Copy link

fatuhoku commented Nov 3, 2014

Views created in XIB doesn't know whether it will be presented under a UINavigationController or not, so when designing the view with IB, it's not possible to create view constraints attached to the top or bottom layout guides, forcing the user to bind to the edges of the superview.

When the XIB is loaded by StoryboardXibController, these views are oblivious to the top and bottom layout guides and so the contents are drawn underneath the navigation bars when they're not supposed to.

@yoiang
Copy link
Member

yoiang commented Nov 3, 2014

Good call!
Let me take a sec to think over a good solution, if you already have one in mind feel free to post it or make a pull request :)

@yoiang yoiang self-assigned this Nov 3, 2014
@fatuhoku
Copy link
Author

fatuhoku commented Nov 3, 2014

@yoiang — thanks for the response. Yes, the solution will need a little thinking and experimentation to get right.

I found http://stackoverflow.com/a/26397943/590767, which is a hack on UIViewController that would replace constraints that bind to the top edge of the XIB to bind instead to the top layout guide. This happens on viewDidLoad. Good start, but not really a generic solution.

If it was a switch that could be activated through user-defined attributes that'd be even better, RBStoryboardLink style.

I don't think RBStoryboardLink's implementation works either, though!

@yoiang
Copy link
Member

yoiang commented Nov 3, 2014

@fatuhoku
39932a6 fixes the stutter, if this looks good to you I'm going to merge it into master and push a new version to Cocoapods.

@fatuhoku
Copy link
Author

fatuhoku commented Nov 4, 2014

Heya @yoiang — thought I wrote a message but it's just disappeared!

Yep the stutter has been fixed. With respect I'm not so sure about the implementation though. Top layout guides and bottom layout guides in iOS 7 generalises the concept of top and bottom bars showing up (navigation bars, toolbars, tab bars, mainly) and whether the view's frame should change to avoid being obscured.

I reckon that would be cleaner than performing custom checks like isWithinNavigationController because that only covers the navigation bar case.

Plus — if you look carefully at the push segue animation, the view actually jumps back to its original position (see below). I'm positive this doesn't happen when using the top layout guide. See SnapKit/Masonry#27.

ios simulator screen shot 3 nov 2014 23 55 55

@yoiang
Copy link
Member

yoiang commented Nov 4, 2014

@fatuhoku ah you're right, for some reason when I tested last night with the topLayoutGuide it wasn't ready in time and was causing more shifting but now it seems to be alright with cleaned up code. I'll clean up the code and push with top and bottom layout guides.

@yoiang
Copy link
Member

yoiang commented Nov 4, 2014

@fatuhoku Alright, now if it looks good I'll merge into master, thanks for pushing to get this working nice and cleanly :)

@yoiang
Copy link
Member

yoiang commented Nov 5, 2014

K, I'm going to merge this in and push it!

@yoiang yoiang closed this as completed Nov 5, 2014
@yoiang
Copy link
Member

yoiang commented Nov 5, 2014

StoryboardXibController 1.7 pushed to Cocoapods
dd6da16

@fatuhoku
Copy link
Author

fatuhoku commented Nov 6, 2014

Sorry I haven't had time to check it. I trust that it's all good though =]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants