gpt4 book ai didi

iphone - 自定义类 "unrecognised selector send to instance"

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

背景故事

我目前正在创建一个自定义类来处理/模仿 Facebook 菜单应用程序的外观,我在一个单独的项目(工作)中创建了这个功能,并认为让代码可重用是个好主意。

问题

我收到“无法识别的选择器发送到实例”错误,虽然我非常确定我已经实现了“句柄”方法,但我无法弄清楚哪里出了问题。如果有人愿意帮助我。或者把我推向正确的方向

编辑

我的输出窗口产生的完整错误

2013-03-06 19:56:39.520 SwipeMenuProject[14347:c07] -[__NSArrayM handle:]: unrecognized selector sent to instance 0x7558310

代码

UISwipeMenuControl.m

#import "UISwipeMenuControl.h"

@implementation UISwipeMenuControl

@synthesize frontWindow = _frontWindow, backWindow = _backWindow, navController = _navController, btnHandle = _btnHandle;

-(id)init
{
self.frontWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.backWindow = [[UIWindow alloc] initWithFrame:CGRectMake(-61,0,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)];

self.btnHandle = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.btnHandle setFrame:CGRectMake(0, 0, 60, 20)];
[self.btnHandle setTitle:@"Handle" forState:UIControlStateNormal];

UIPanGestureRecognizer * dragGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handle:)];
[self.btnHandle addGestureRecognizer:dragGesture];

UIViewController * viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[viewController setTitle:@"Swipe Menu"];
[viewController.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:self.btnHandle]];

self.navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.frontWindow setRootViewController:self.navController];

return self;
}

-(UIWindow *)getFrontWindow
{
return self.frontWindow;
}

-(UIWindow *)getBackWindow
{
return self.backWindow;
}

-(UINavigationController *)getNavigationController
{
return self.navController;
}

-(void) setRootViewController:(UIViewController *)viewController
{
self.navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:self.btnHandle]];
[self.frontWindow setRootViewController:self.navController];
}
-(void)handle:(id)sender
{
//unrelated code here
}

Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UISwipeMenuControl * swipeMenu = [[UISwipeMenuControl alloc] init];

CustomViewController * cViewController = [[CustomViewController alloc] initWithNibName:nil bundle:nil];
[swipeMenu setRootViewController:cViewController];

self.window = [swipeMenu getFrontWindow];
[self.window setBackgroundColor:[UIColor redColor]];
[self.window makeKeyAndVisible];

return YES;
}

最佳答案

看起来这是一个所有权/内存问题。 UISwipeMenuControl 似乎在识别器发送其操作时被释放。

让僵尸能够调查是否是问题所在。

关于iphone - 自定义类 "unrecognised selector send to instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15256066/

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