ealeksandrov / EAIntroView

Highly customizable drop-in solution for introduction views.
MIT License
3.76k stars 501 forks source link

show Intro With Custom View From storyboard instead of Nib? #166

Open oenama opened 8 years ago

oenama commented 8 years ago

is it possible to show Intro With Custom View From storyboard instead of Nib(xib file) ?

ealeksandrov commented 8 years ago

It is not supported right now and not a short-term feature. But I am open to discussion and implementing it in future releases.

How do you want it to look? Storyboards can only store views inside ViewControllers. One possible idea is to make EAIntroView as some sort of container with pages as child views. http://stackoverflow.com/a/21946121/840588

alejandroivan commented 8 years ago

In theory, he could do it assigning an identifier to a view controller and then messaging the instantiateViewControllerWithIdentifier: method on a UIStoryboard instance. Something like:

#import "AppDelegate.h"
#import "EAIntroPage.h"

UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
UIStoryboard *storyboard = [[window rootViewController] storyboard];

UIViewController *newVC = [storyboard instantiateViewControllerWithIdentifier:@"SomeIdentifier"];
UIView *vcView = [newVC view];

EAIntroPage *page = [EAIntroPage pageWithCustomView:vcView];

I could be wrong, but I see no reason for this to fail.

GabLeRoux commented 7 years ago

I confirm the above solution does work.

On the other hand, I currently have troubles with Auto Layout and Constraints for theses views within the storyboard. Starting them manually displays them fine (ex: by setting the view as initial view controller). When I load them trough EAIntroPage, sometimes, positions are ok, sometimes they are not and the behaviour changes each time I showInView (display the introduction view, without leaving the app).

I may send a PR with examples if I get something working out of it.