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

Layout guides and iOS 9 support #214

Merged
merged 3 commits into from
Jun 30, 2015
Merged

Conversation

CraigSiemens
Copy link
Contributor

For #207

This adds properties on UIViewController to get the MASViewAttribute for top and bottom layout guides. This works on iOS 7, 8 and 9.

@cloudkite
Copy link
Contributor

@CraigSiemens Awesome work! Sorry for the delay!

cloudkite added a commit that referenced this pull request Jun 30, 2015
@cloudkite cloudkite merged commit d2bd374 into SnapKit:master Jun 30, 2015
@neilkimmett
Copy link

Would you mind doing a new CocoaPods release with this in?

@cloudkite
Copy link
Contributor

This is now on cocoapods in v0.6.2

@neilkimmett
Copy link

Nice one, thanks @cloudkite 😊

@johnryan
Copy link

@cloudkite I'm still seeing the issue

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UILayoutSpacer mas_bottom]: unrecognized selector sent to instance 0x14ee7c4d0'

in 0.6.2

when I do this

UIView *topLayoutGuide = (UIView *)self.topLayoutGuide;
make.top.equalTo(topLayoutGuide.mas_bottom).offset(10);

Any suggestions?

@CraigSiemens
Copy link
Contributor Author

That way no longer works in iOS 9. You will need to use the new layout guide attributes added to UIViewController by this pull request.

make.top.equalTo(self.mas_topLayoutGuide).offset(10);

@johnryan
Copy link

Ah, got it thanks

@kmikael
Copy link

kmikael commented Sep 14, 2015

I tried 0.6.2 and the current master branch and this issue is not fixed for me. I'm using Xcode 7.0 (7A218), that is the GM.

2015-09-14 13:59:22.749 Redacted[8383:570860] -[_UILayoutSpacer mas_bottom]: unrecognized selector sent to instance 0x7fc43cd6e4d0
2015-09-14 13:59:22.775 Redacted[8383:570860] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UILayoutSpacer mas_bottom]: unrecognized selector sent to instance 0x7fc43cd6e4d0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000107ea0f65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000106920deb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000107ea958d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000107df6f7a ___forwarding___ + 970
    4   CoreFoundation                      0x0000000107df6b28 _CF_forwarding_prep_0 + 120
    5   Redacted                            0x0000000105b80760 __41-[IdentCodeViewController viewDidLoad]_block_invoke50 + 736
    6   Redacted                            0x00000001053ac5fa -[UIView(MASAdditions) mas_makeConstraints:] + 138
    7   Redacted                            0x0000000105b7fed3 -[IdentCodeViewController viewDidLoad] + 1827
    8   UIKit                               0x00000001094c2931 -[UIViewController loadViewIfRequired] + 1344
    9   UIKit                               0x00000001094c2c7d -[UIViewController view] + 27
    10  Redacted                            0x0000000105b43f2f -[IdentificationViewController viewDidLoad] + 991
    11  UIKit                               0x00000001094c2931 -[UIViewController loadViewIfRequired] + 1344
    12  UIKit                               0x00000001094c2c7d -[UIViewController view] + 27
    13  UIKit                               0x0000000109513612 -[UINavigationController preferredContentSize] + 194
    14  UIKit                               0x000000010949a018 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 59
    15  UIKit                               0x00000001094964ef __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 95
    16  UIKit                               0x00000001093434be _runAfterCACommitDeferredBlocks + 317
    17  UIKit                               0x00000001093557ee _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
    18  UIKit                               0x00000001093614e6 _afterCACommitHandler + 90
    19  CoreFoundation                      0x0000000107dcc9d7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    20  CoreFoundation                      0x0000000107dcc947 __CFRunLoopDoObservers + 391
    21  CoreFoundation                      0x0000000107dc259b __CFRunLoopRun + 1147
    22  CoreFoundation                      0x0000000107dc1e98 CFRunLoopRunSpecific + 488
    23  GraphicsServices                    0x000000010caf0ad2 GSEventRunModal + 161
    24  UIKit                               0x0000000109337676 UIApplicationMain + 171
    25  Redacted                            0x00000001050cf7f7 main + 343
    26  libdyld.dylib                       0x000000010bdf892d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@CraigSiemens
Copy link
Contributor Author

Casting the topLayoutGuide to a UIViewno longer works in iOS 9. The proper way to layout using the layout guides is to use the mas_topLayoutGuide and mas_bottomLayoutGuide on UIViewContorller

It should look like this

make.top.equalTo(self.mas_topLayoutGuide).offset(10);

There is also an example in MASExampleLayoutGuideViewController.m

@kmikael
Copy link

kmikael commented Sep 14, 2015

Thanks. Sadly, we are using a closed-source third party SDK that uses Masonry, so we can't do anything about it. But just now we found a way to swizzle the required methods into _UILayoutSpacer and now it works again. Hopefully that third party SDK will be updated soon.

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

Successfully merging this pull request may close these issues.

5 participants