1

背景故事

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

问题

我收到“无法识别的选择器发送到实例”错误,而我确实确定我已经实现了“处理”方法,但我无法弄清楚出了什么问题。如果有人愿意帮助我。或者把我推向正确的方向

编辑

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

2013-03-06 19:56:39.520 SwipeMenuProject[14347:c07]-[__NSArrayM 句柄:]:无法识别的选择器发送到实例 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;
}
4

1 回答 1

2

看起来这是一个所有权/内存问题。UISwipeMenuControl当识别器发送它的动作时,它似乎被释放了。

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

于 2013-03-06T19:26:27.827 回答