Question

I'm using ICETutorial with cocoapods.

I'm using it in a SettingsViewController where you can view the tutorial in settings.

// SettingsViewController.m
Tutorial2ViewController *vc = [[Tutorial2ViewController alloc] init];
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController pushViewController:vc animated:NO];

And Tutorial2ViewController inherits from ICETutorialController

@interface Tutorial2ViewController : ICETutorialController

ICETutorialPages have buttons that will trigger a callback. It takes in a block. So in my implementation, I have this:

- (id)init
{
    ICETutorialPage *layer1 = [[ICETutorialPage alloc] initWithSubTitle:@"Page 1" description:@"Page 1" pictureName:@"Tutorial1_640x1136.png"];
    NSArray *tutorialLayers = @[layer1];

    self = [super initWithNibName:@"ICETutorialController_iPhone" bundle:nil andPages:tutorialLayers];

    __weak Tutorial2ViewController *vc = self;
    [self setButton1Block:^(UIButton *button){
        NSLog(@"Button 1 pressed.");
        [[vc.navigationController topViewController] dismissViewControllerAnimated:NO completion:nil];
    }];

    if (self != nil)
    {

    }
    return self;
}

The reason why I put all the code in init is that I don't want SettingsViewController to know anything about how the Tutorial2ViewController works. Settings should alloc and init, push to the navigation controller stack and the Tutorial2ViewController should know how to handle itself.

I do get the NSLog that button1 is pressed but the view controller does not dismiss itself and return me to the SettingsViewController.

I will contact the creator of the library and ask him/her to see this question also. I feel that this is me not misunderstanding blocks, navigation controllers, cocoapods, etc...

Thanks

Was it helpful?

Solution

Just try [self.navigationController popViewControllerAnimated:YES];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top