在页面视图控制器中直接设置pageIndex时出错

时间:2014-04-22 01:08:01

标签: ios uipageviewcontroller

我正在使用页面视图控制器和表格视图。当我在表格视图中选择一个单元格时,我想直接进入该页面。但是,当我点击表格视图单元格时,应用程序崩溃了。

  

由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' * - [__ NSPlaceholderArray initWithObjects:count:]:尝试从对象[0]中插入nil对象

这是我的代码..

**来自PageViewLatestIssueController **

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

 [self.tv_tableOfContents deselectRowAtIndexPath:indexPath animated:YES];


  LatestIssueController *lic = [self.storyboard instantiateViewControllerWithIdentifier:@"LatestIssueController"];

    if ([[self.arrayPages objectAtIndex:indexPath.row] isEqualToString:@“13”]) {
        lic.pageIndex = 5;
        [lic goToPage];
    }else if([[self.arrayPages objectAtIndex:indexPath.row] isEqualToString:@"15"]){
        lic.pageIndex = 7;
        [lic goToPage];
    }else{
        ….
    }  
}

**来自LatestIssueController **

- (无效)GotoPage记述{

    self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewLatestIssue"];
    self.pageViewController.dataSource = self;

    PageViewLatestIssueController *startingViewController = [self viewControllerAtIndex:self.pageIndex];
    NSArray *viewControllers = @[startingViewController];
    [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];

    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
    [self.pageViewController didMoveToParentViewController:self];
}

0 个答案:

没有答案