mamaral / Onboard

An iOS framework to easily create a beautiful and engaging onboarding experience with only a few lines of code.
MIT License
6.46k stars 765 forks source link

Nothing happens #107

Closed fabdurso closed 8 years ago

fabdurso commented 8 years ago

I'd like to show Onboard at first time launch, but right now nothing appears. This is my code:


#import "OnboardingViewController.h"
@interface ViewController ()

@implementation ViewController
#
#
#
-(void)firstTimePopup{

    OnboardingContentViewController *firstPage = [OnboardingContentViewController contentWithTitle:@"Welcome" body:@"body." image:[UIImage imageNamed:@"logo"] buttonText:@"Text For Button" action:^{
    }];
    OnboardingContentViewController *secondPage = [OnboardingContentViewController contentWithTitle:@"Welcome" body:@"body." image:[UIImage imageNamed:@"logo"] buttonText:@"Text For Button" action:^{
    }];
    OnboardingViewController *onboardingVC = [OnboardingViewController onboardWithBackgroundImage:[UIImage imageNamed:@"bg"] contents:@[firstPage, secondPage]];
    [self presentViewController:onboardingVC animated:YES completion:nil];
end

what am I missing?

mamaral commented 8 years ago

Have you tried self.navigationController instead?

fabdurso commented 8 years ago

[self.navigationController presentViewController:onboardingVC animated:YES completion:nil];

stille the same :(

mamaral commented 8 years ago

You put this code inside a view controller - what are you doing with the view controller itself? How/where do you create/show it.

fabdurso commented 8 years ago

ok so... I'm calling firstTimePopup from my viewDidLoad when the user launches the app for the first time. is there something else I should add?

mamaral commented 8 years ago

I don't know enough about what you're doing. The view controller you showed the file for, is that being shown on screen?

fabdurso commented 8 years ago

The ViewController is my "homepage", that is showing correctly. Now on ViewController.m, in the viewDidLoad I check if it's user first use and if so, I call firstTimePopup, that should show the onboardingvc.

i know i'm missing something elementary but can't figure out what.

mamaral commented 8 years ago

It sounds like a very simple issue - you're missing something somewhere. Have you tried presenting a normal UIViewController instead of the onboarding view controller? Have you tried moving that code somewhere outside of viewDidLoad, perhaps viewDidAppear?

fabdurso commented 8 years ago

Yes, I called it from a button and it works! So should I move the code to viewDidAppear?

mamaral commented 8 years ago

Sounds like your timing was bad - you never want to present a view controller in viewDidLoad, as that can be called before that view controller is even shown on screen. I would suggest moving it to viewDidAppear, which will onboard slightly after the original view controller is seen.

fabdurso commented 8 years ago

I did it and it doesn't show up.

mamaral commented 8 years ago

It shows up on button click, but not in viewDidAppear?

fabdurso commented 8 years ago

exactly

mamaral commented 8 years ago

That sounds really odd... Without looking at more of the code, setting my own breakpoints/logs, etc., I'm not sure I can help. Presenting a view controller is about as simple as it gets - but I don't really have enough info to debug remotely.

fabdurso commented 8 years ago

Ok so i found a way. Not move all the code to viewDidLoad but just [self firstTimePopup]. It is working now.

fabdurso commented 8 years ago

And like a charm. Amazing job man! Thank you for the support!

mamaral commented 8 years ago

No problem, glad to help!