didSelectRowAtIndexPath不被框架中的UITableViewController调用

问题描述:

我创建了一个包含UITableViewController的框架。出于某种原因,当我使用这个框架并创建这个VC时,它完美地加载并且数据源方法工作得很好,而且看起来就像它应该那样。但是,当我单击单元格时绝对没有任何反应。我知道它应该工作,因为当我在框架中使用这个VC时,它工作正常。didSelectRowAtIndexPath不被框架中的UITableViewController调用

我只是NSLog语句设置为didSelectRowAtIndexPath,但它们根本不被调用。为什么会从框架中使用这个VC使didSelectRowAtIndexPath不被调用?

编辑:我发现这个问题与我使用的SlidingNavigationController有关。

具体来说,如果我在applicationDidFinishLaunchingWithOptions使用下面的代码,然后一切工作正常:

NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Lights" ofType:@"bundle"]; 
    NSBundle *lights = [NSBundle bundleWithPath:bundlePath]; 

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:lights]; 
    SlideNavigationController *nc = (SlideNavigationController*)[sb instantiateViewControllerWithIdentifier: @"SlideNavigationController"]; 
    ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"ViewController"]; 

    MenuViewController * _mvc = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle: lights]; 
    [SlideNavigationController sharedInstance].leftMenu = _mvc; 
    [SlideNavigationController sharedInstance].rightMenu = vc; 
    self.window.rootViewController = nc; 

不过,如果我使用相同的代码,其他地方在我的项目(例如,在VC按钮启动此storyboard序列),TableView不响应。

将代码放在didFinishLaunching中有什么特别之处?

+0

你编程创建'tableview'?你可以分享一些代码吗? – casillas

+0

你确认UITableViewDelegate协议吗? – iMuzahid

+0

@casillas @ Md.Muzahidul* - 刚添加了代码 – Jameson

好吧,我的回答是,如果您的UITableViewDelegate方法在MenuViewController实施,然后删除您的下面的代码。

leftMenu.tableView.delegate = self;

和内部的MenuViewController告诉tableViewself的委托,如:

// in MenuViewController.m 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.tableView.delegate = self; 
} 
+0

是的,这已经完成了。我相信我已经将问题限制在SlideNavigationController上 - 当我使用常规NC时,这个问题不会发生。 – Jameson

+0

然后显示你的'SlideNavigationController'的实现。它是如何实现的? – Shamsiddin

+0

任何偶然键入'didDeselectRowAtIndexPath'而不是'didSelectRowAtIndexPath'的机会? – Shamsiddin