gpt4 book ai didi

iOS UIPageViewController - 由于未捕获的异常 'Invalid parameter not satisfying: [views count] == 3' 而终止应用程序

转载 作者:行者123 更新时间:2023-11-29 13:03:02 25 4
gpt4 key购买 nike


我有一个页面 View Controller ,但出现错误Termating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfy: [views count] == 3'

这是我的数据源:

//
// MSABDrawingPageModelController.m
// My Special Alphabet Book
//
// Created by Ari Porad on 9/3/13.
// Copyright (c) 2013 Cari Books. All rights reserved.
//

#import "MSABDrawingPageModelController.h"
#import "MSABDrawingViewController.h"
#import "MSABDrawingView.h"

@implementation MSABDrawingPageModelController

-(id)initWithLetter:(MSABLetter *)letter{
if (self = [super init]) {
self.letter = letter;
}
return self;
}

-(id)init{
return [self initWithLetter:nil];
}

-(NSURL *)docsDirUrl{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] objectAtIndex:0];
}

-(UIViewController *)viewControllerAtIndex:(int)index{
MSABDrawingViewController *VC = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MSAB_DRAWING_VIEW_CONTROLLER"];

((MSABDrawingView *) VC.view).points = [NSMutableArray arrayWithArray:@[[NSMutableArray array]]];
VC.index = index;
VC.letter = self.letter;

return VC;
}

#pragma mark -
#pragma mark Page View Controller Data Source Methods

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
UIViewController *vc = [self viewControllerAtIndex:((MSABDrawingViewController *)viewController).index + 1];
if(vc == nil){
vc = [[MSABDrawingViewController alloc] init];
}
NSLog(@"AVC: %@", vc);
return vc;
}

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
UIViewController *vc = [self viewControllerAtIndex:((MSABDrawingViewController *)viewController).index - 1];
if(vc == nil){
vc = [[MSABDrawingViewController alloc] init];
}
NSLog(@"PVC: %@", vc);
return vc;
}

@end

如果您还有其他需要了解的信息,请告诉我。

最佳答案

我遇到了同样的问题。

事实证明,无论是通过 IB 设置还是以编程方式设置,都必须设置 uipageviewcontroller 的初始 View Controller 。

来源: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/PageViewControllers.html#//apple_ref/doc/uid/TP40011313-CH4-SW10

调用 setViewControllers:direction:animated:completion: 方法并设置初始 View Controller 数组。

关于iOS UIPageViewController - 由于未捕获的异常 'Invalid parameter not satisfying: [views count] == 3' 而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19337679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com