【发布时间】:2015-11-15 01:11:24
【问题描述】:
我不想在我的应用程序中使用 SWRevealViewController,因为我按照给定的链接“https://www.youtube.com/watch?v=5SUV1YY2yxQ”执行步骤。
但是我的应用程序在这一行崩溃了
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
编译器显示以下错误
由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'*** -[__NSArrayM insertObject:atIndex:]: 对象不能为 nil'。
请检查我的故事板设计
下面是我想要打开显示视图控制器.h 文件的蓝色背景视图代码
#import <UIKit/UIKit.h>
#import "SWRevealViewController.h"
@interface DashboardSixOptionViewController : UIViewController
{
SWRevealViewController *revealViewController;
}
@property (nonatomic,retain) SWRevealViewController *revealViewController;
@end
.m 文件
@interface DashboardSixOptionViewController ()
@end
@implementation DashboardSixOptionViewController
@synthesize revealViewController = _revealViewController;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"gesture desc::%@",self.revealViewController.panGestureRecognizer);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
-(void)configureView
{
[self.navigationController.navigationBar setTintColor:[UIColor orangeColor]];
CGRect dashboardNavFrame = self.navigationController.navigationBar.bounds;
// dashboardNavFrame.size.height += 5;
self.toolBar = [[UIToolbar alloc] initWithFrame:dashboardNavFrame];
[self.toolBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.toolBar setTintColor:[UIColor redColor]];
//disable any back btn
self.toolBar.clearsContextBeforeDrawing = NO;
self.toolBar.clipsToBounds = NO;
[self.toolBar setTag:700];
NSMutableArray *buttons = [[NSMutableArray alloc] init];
UIImage *imgOption;
imgOption = [UIImage imageNamed:@"imgOptionsIOS7.png"];
UIButton *aOptionButton = [UIButton buttonWithType:UIButtonTypeCustom];
// [aOptionButton setEnabled:NO];
aOptionButton.frame = CGRectMake(0, 0, imgOption.size.width, imgOption.size.height);
[aOptionButton setImage:imgOption forState:UIControlStateNormal];
// [aOptionButton addTarget:self action:@selector(showLeftMenu:) forControlEvents:UIControlEventTouchUpInside];
[aOptionButton addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:aOptionButton];
[btn setTarget:self.revealViewController];
[btn setAction:@selector(revealToggle:)];
[buttons addObject:btn];
[self.toolBar setItems:buttons animated:YES];
[self.navigationController.navigationBar addSubview:self.toolBar];
}
从视图控制器 DashboardSixOptionView 视图推送下面是我的代码
DashboardSixOptionView = [mainStoryboard instantiateViewControllerWithIdentifier:@"DashboardStoryBoardWithSixOption"];
DashboardSixOptionView.arrTableViewHreaders = self.arrForMenuOption;
[self.navigationController pushViewController:DashboardSixOptionView animated:YES];
请帮我看看我为什么会崩溃。
提前致谢 普里扬卡
【问题讨论】:
标签: ios objective-c swrevealviewcontroller