0

我的应用程序有一点问题。

我正在使用 ECSlidingViewController。

这是一个概述:

在此处输入图像描述

在 ViewController.h 上:

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "ECSlidingViewController.h"
#import "MenuViewController.h"

@interface ViewController : UIViewController

@property (strong, nonatomic) UIButton *menuBtn;

@end

在 ViewController.m 上:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize menuBtn;

- (void)viewDidLoad
{
    [super viewDidLoad];


    self.view.layer.shadowOpacity = 0.75f;
    self.view.layer.shadowRadius = 10.0f;
    self.view.layer.shadowColor = [UIColor blackColor].CGColor;


    if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
    }


    [self.view addGestureRecognizer:self.slidingViewController.panGesture];


    self.menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    menuBtn.frame = CGRectMake(20, 27, 25, 21);
    [menuBtn setBackgroundImage:[UIImage imageNamed:@"menuButton.png"] forState:UIControlStateNormal];
    [menuBtn addTarget:self action:@selector(revealMenu:) forControlEvents:UIControlEventTouchUpInside];


    [self.view addSubview:self.menuBtn];


}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.view.layer.shadowOpacity = 0.75f;
    self.view.layer.shadowRadius = 10.0f;
    self.view.layer.shadowColor = [UIColor blackColor].CGColor;
    if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
    }

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}




- (IBAction)revealMenu:(id)sender
{
    [self.slidingViewController anchorTopViewTo:ECRight];
}

@end

当我单击 View Controller 上的按钮时,它会创建 ECSliding 效果,调出 MenuViewController。在 MenuViewController 内部,还有另一个按钮,它会调出 testeViewController。

在 testeViewController.h 和 testeViewController.m 上,我添加了与 ViewController 中完全相同的代码。但是,当我单击 MenuViewController 内的按钮以调出 testeViewcController 时,应用程序崩溃,并出现以下错误:

2013-08-04 18:50:16.174 FacttoBraziliPhone1[21477:c07] *** Terminating app due to uncaught         exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x15ad012 0x12bae7e 0x1560b6a 0x1560a20 0x24ea3f 0xd01b 0x2e01c7 0x2e0232 0x2e04da 0x2f78e5 0x2f79cb 0x2f7c76 0x2f7d71 0x2f889b 0x2f8e93 0x2f8a88 0x654e63 0x646b99 0x646c14 0x12ce705 0x2022c0 0x202258 0x2c3021 0x2c357f 0x2c26e8 0x231cef 0x231f02 0x20fd4a 0x201698 0x260fdf9 0x260fad0 0x1522bf5 0x1522962 0x1553bb6 0x1552f44 0x1552e1b 0x260e7e3 0x260e668 0x1feffc 0x284d 0x2775)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

如果 ViewController 应该等于 testeViewController,为什么我会崩溃?有任何想法吗?

谢谢!

4

1 回答 1

0

这可能是ECSlidingViewController. 我会至少升级到 1.0.1 版。

于 2013-11-16T18:11:50.520 回答