OAStackView icon indicating copy to clipboard operation
OAStackView copied to clipboard

UIStackView for iOS9

Open sjapps opened this issue 10 years ago • 16 comments
trafficstars

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

sjapps avatar Jun 16 '15 13:06 sjapps

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

delebedev avatar Jun 16 '15 13:06 delebedev

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.

nsomar avatar Jun 16 '15 22:06 nsomar

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 avatar Jun 21 '15 23:06 steipete

@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 :)

nsomar avatar Jun 24 '15 18:06 nsomar

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

fbartho avatar Jul 08 '15 23:07 fbartho

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.

natanrolnik avatar Aug 05 '15 14:08 natanrolnik

It might be more reliable to use an NSProxy instead.

harlanhaskins avatar Aug 05 '15 15:08 harlanhaskins

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?

natanrolnik avatar Aug 05 '15 15:08 natanrolnik

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

mthole-old avatar Aug 15 '15 00:08 mthole-old

Another vote here for @compatibility_alias

harlanhaskins avatar Aug 15 '15 00:08 harlanhaskins

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

natanrolnik avatar Aug 16 '15 12:08 natanrolnik

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

m1entus avatar Oct 15 '15 09:10 m1entus

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

mindz-eye avatar Feb 24 '16 08:02 mindz-eye

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.

m1entus avatar Feb 24 '16 08:02 m1entus

I see. Thanks!

mindz-eye avatar Feb 24 '16 08:02 mindz-eye

@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.

fbartho avatar Feb 24 '16 21:02 fbartho