'NSInvalidArgumentException',原因:'-[__NSCFSet addObject:]:尝试插入 nil'
当我运行下面的代码时,为什么我在 iPhone 5.1 而不是在 6.0 模拟器中得到这个异常?此代码用于幻灯片视图控制器,5.1 支持吗?
- (NSArray*)controllers {
NSMutableArray *result = [NSMutableArray array];
if (self.centerController) [result addObject:self.centerController];
if (self.leftController) [result addObject:self.leftController];
if (self.rightController) [result addObject:self.rightController];
if (self.topController) [result addObject:self.topController];
if (self.bottomController) [result addObject:self.bottomController];
return [NSArray arrayWithArray:result];
}
我认为这就是凯文正在寻找的。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
IIViewDeckController* deckController = [self generateControllerStack];
self.leftController = deckController.leftController;
self.centerController = deckController.centerController;
/* To adjust speed of open/close animations, set either of these two properties. */
// deckController.openSlideAnimationDuration = 0.15f;
// deckController.closeSlideAnimationDuration = 0.5f;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
return YES;
}
- (IIViewDeckController*)generateControllerStack {
LeftViewController* leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
RightViewController* rightController = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];
UIViewController *centerController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
centerController = [[UINavigationController alloc] initWithRootViewController:centerController];
IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:centerController
leftViewController:leftController
rightViewController:rightController];
deckController.rightSize = 100;
[deckController disablePanOverViewsOfClass:NSClassFromString(@"_UITableViewHeaderFooterContentView")];
return deckController;
}