nsomar / OAStackView

Porting UIStackView to iOS 7+
MIT License
2.14k stars 200 forks source link

UIStackView for iOS9 #2

Open sjapps opened 9 years ago

sjapps commented 9 years ago

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

delebedev commented 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

nsomar commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

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

natanrolnik commented 8 years ago

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 commented 8 years ago

It might be more reliable to use an NSProxy instead.

natanrolnik commented 8 years ago

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 commented 8 years ago

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

harlanhaskins commented 8 years ago

Another vote here for @compatibility_alias

natanrolnik commented 8 years ago

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

m1entus commented 8 years ago

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

mindz-eye commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

I see. Thanks!

fbartho commented 8 years ago

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