Open sjapps opened 9 years ago
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
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.
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.
@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 :)
@oarrabi I definitely support this issue. Very much desire the PSTCollectionView strategy so we use Apple's implementation on iOS 9. :+1:
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.
It might be more reliable to use an NSProxy
instead.
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?
How about just using @compatibility_alias
? See http://nshipster.com/at-compiler-directives/
Another vote here for @compatibility_alias
Indeed that's great! Thanks for the suggestion, I wasn't aware about it, @mthole and @harlanhaskins
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 https://github.com/oarrabi/OAStackView/pull/60
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
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.
I see. Thanks!
@mindz-eye If you're not interested in ASM instructions: you could probably pull in the relevant file from this PR for your UIStackView https://github.com/tomvanzummeren/TZStackView/pull/61. It uses a preprocessor trick rather than assembly to make Objective-C work seamlessly. -- Doesn't work for Interface Builder.
This is nice for backward capability but will this use UIStackView if it's on iOS9?