Question

I'm loading my view controllers like this:

NSArray *viewControllerNames = [NSArray arrayWithContentsOfFile:path];
    for (NSString *viewControllerClass in viewControllerNames) {

        NSString *filePath = [self filePathForClass:NSClassFromString(viewControllerClass)];
        if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
            id viewController = [NSKeyedUnarchiver unarchiveObjectWithData:[NSData dataWithContentsOfFile:filePath]];

            [self pushViewController:viewController animated:NO];
        }
    }

On my stack's root view controller I am adding a gesture recognizer in the navbar.

However if I pushed some view controller on top it won't load this gesture, because the root view controller's viewDidLoad doesn't get called, and if I access the viewControllers property of UINavigationController it returns nil.

Any ideas how to proceed with this gesture? Thanks!

Was it helpful?

Solution

How about using setViewControllers:animated: instead of pushing single view controller one by one?

NSMutableArray * viewControllers = [[NSMutableArray alloc] init];
for(...) { // the same for loop you have 
    ...
    [viewControllers addObject:viewController];
}
[self setViewControllers:viewControllers animated:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top