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

UIStackView for iOS9 #2

Open
sjapps opened this issue Jun 16, 2015 · 16 comments
Open

UIStackView for iOS9 #2

sjapps opened this issue Jun 16, 2015 · 16 comments

Comments

@sjapps
Copy link

sjapps commented Jun 16, 2015

This is nice for backward capability but will this use UIStackView if it's on iOS9?

@delebedev
Copy link
Collaborator

Maybe it makes sense to use approach from here to fallback to original iOS 9 implementation: https://github.com/steipete/PSTCollectionView/blob/master/PSTCollectionView/PSTCollectionView.h

@nsomar
Copy link
Owner

nsomar commented Jun 16, 2015

I am still not sure about how to approach fallback here, as most of the time you would use the stackview from the interface builder. PSUICollectionView sounds very promising.

@steipete
Copy link

There are ways to parse things from the interface builder by reading the undocumented keys from NSCoder - we did that in PSTCollectionView as well. It's quite a lot trial and error though. I'd first aim for source code level compatibility before starting that task.

@nsomar
Copy link
Owner

nsomar commented Jun 24, 2015

@steipete Thanks for the info, that is very helpful!, Indeed I still have a couple of loose ends to tie in order to be feature complete. I will definitely checkout PSTCollectionView as a reference on how to do seamless integration with backward compatibility.

Thanks :)

@fbartho
Copy link

fbartho commented Jul 8, 2015

@oarrabi I definitely support this issue. Very much desire the PSTCollectionView strategy so we use Apple's implementation on iOS 9. 👍

@natanrolnik
Copy link

I did the initial part of what @steipete suggested - I created a solution that handles that, but only on code - I called it StackViewProxy. (Any suggestions for a better name?)
I will create a PR soon, but basically, it is a UIView that has the stack view (UIStackView on iOS 9, OAStackView on iOS 8), and passes on to the correct and existing stack view.

@harlanhaskins
Copy link
Contributor

It might be more reliable to use an NSProxy instead.

@natanrolnik
Copy link

You are right. But I want it to work like this

myView.addSubview(stackViewProxy)

Using the UIView approach, it would work. Can the same be said with the NSProxy approach?

@mthole-old
Copy link

How about just using @compatibility_alias? See http://nshipster.com/at-compiler-directives/

@harlanhaskins
Copy link
Contributor

Another vote here for @compatibility_alias

@natanrolnik
Copy link

Indeed that's great! Thanks for the suggestion, I wasn't aware about it, @mthole and @harlanhaskins

@m1entus
Copy link
Contributor

m1entus commented Oct 15, 2015

I made a better way to maintain this, using runtime injection for <iOS9, this allow you to maintain OAStackView as normal UIStackView on storyboard, reference #60

@mindz-eye
Copy link

Runtime injection doesn't work for me for some reason.
[[UIStackView alloc] init] returns nil, while objc_getClass("UIStackView") returnes a valid class.
iOS 8.3

@m1entus
Copy link
Contributor

m1entus commented Feb 24, 2016

For UIStackView alloc] init you would need asm instruction to swich UIStackView symbols like here: https://github.com/forkingdog/FDStackView/blob/master/FDStackView/FDStackView.m#L240 which authors didn't want to include. UIStackView works from storyboard fine.

@mindz-eye
Copy link

I see. Thanks!

@fbartho
Copy link

fbartho commented Feb 24, 2016

@mindz-eye If you're not interested in ASM instructions: you could probably pull in the relevant file from this PR for your UIStackView tomvanzummeren/TZStackView#61. It uses a preprocessor trick rather than assembly to make Objective-C work seamlessly. -- Doesn't work for Interface Builder.

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

No branches or pull requests

10 participants