gpt4 book ai didi

ios - self.revealViewController.panGestureRecognizer 在 iOS SWRevealViewController 中显示为空

转载 作者:行者123 更新时间:2023-11-29 12:15:27 25 4
gpt4 key购买 nike

我不想在我的应用程序中使用 SWRevealViewController,因为我按照给定链接“https://www.youtube.com/watch?v=5SUV1YY2yxQ”中的步骤进行操作。

但是我的应用程序在这一行崩溃了

[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];

编译器显示以下错误

terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'.

请检查我的 Storyboard设计

attached is my story board design--- here Reveal View Controller is my initial view from this view connection segue 1 for left menu list (Simple view controller table view added programmatically) 2 for subclass of navigation controller and view controller is my root view controller..after submitting right credential application push next view i.e. Dashboard six option view controller (which has blue background)

DashBoardSixOptionViewController

下面是我的蓝色背景 View 代码,我想在其中打开显示 View Controller .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];

}

从 View Controller DashboardSixOptionView View 以编程方式推送下面是我的代码

DashboardSixOptionView  = [mainStoryboard instantiateViewControllerWithIdentifier:@"DashboardStoryBoardWithSixOption"];
DashboardSixOptionView.arrTableViewHreaders = self.arrForMenuOption;
[self.navigationController pushViewController:DashboardSixOptionView animated:YES];

请帮我弄清楚为什么我会崩溃。

提前致谢朴雅卡

最佳答案

我猜 self.revealViewController.panGestureRecognizernil,因为您为 SWRevealViewController 创建了一个属性,但没有在 viewDidLoad 中分配任何值

您是否在 Storyboard 中正确设置了所有类?

另外,为什么要为 SWRevealViewController 使用 @synthesize 和类变量?没有必要再这样做了。

我建议你看看this great tutorial用于 SWRevealViewController。

关于ios - self.revealViewController.panGestureRecognizer 在 iOS SWRevealViewController 中显示为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32134407/

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