Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 导航栏上的状态保存、导航控制器堆栈保存和手势识别器_Iphone_Ios_Cocoa Touch_State Saving - Fatal编程技术网

Iphone 导航栏上的状态保存、导航控制器堆栈保存和手势识别器

Iphone 导航栏上的状态保存、导航控制器堆栈保存和手势识别器,iphone,ios,cocoa-touch,state-saving,Iphone,Ios,Cocoa Touch,State Saving,我正在加载视图控制器,如下所示: NSArray *viewControllerNames = [NSArray arrayWithContentsOfFile:path]; for (NSString *viewControllerClass in viewControllerNames) { NSString *filePath = [self filePathForClass:NSClassFromString(viewControllerClass)];

我正在加载视图控制器,如下所示:

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];
        }
    }
在堆栈的根视图控制器上,我在导航栏中添加了一个手势识别器

但是,如果我将某个视图控制器推到顶部,它将不会加载此手势,因为不会调用根视图控制器的
viewDidLoad
,如果我访问
UINavigationController
viewControllers
属性,它将返回nil


你知道怎么做这个手势吗?谢谢

使用
setViewControllers:animated:
而不是逐个按下单个视图控制器怎么样

NSMutableArray * viewControllers = [[NSMutableArray alloc] init];
for(...) { // the same for loop you have 
    ...
    [viewControllers addObject:viewController];
}
[self setViewControllers:viewControllers animated:YES];

UINavigationController没有这样的选择器。抱歉,这是一个输入错误。它应该是
setViewControllers:animated:
而不是
addViewControllers:animated: