【发布时间】:2016-03-21 16:05:02
【问题描述】:
我创建了一个包含UITableViewController 的框架。出于某种原因,当我使用这个框架并创建这个 VC 时,它可以完美地加载,并且数据源方法工作得很好,看起来就像它应该的那样。但是,当我单击单元格时,绝对没有任何反应。我知道它应该可以工作,因为当我在框架中使用这个 VC 时,它可以正常工作。
我只是为didSelectRowAtIndexPath 设置了NSLog 语句,但根本没有调用它们。为什么在框架中使用这个 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 有什么特别之处?
【问题讨论】:
-
您是否正在以编程方式创建
tableview?你能分享一些代码吗? -
你确认 UITableViewDelegate 协议了吗?
-
@casillas @ Md.Muzahidul Islam -- 刚刚添加了代码
-
您的
tableView存储在MenuViewController中吗?如果是这样,您的UITableViewDelegate方法在哪里实现? -
委托方法在 MenuViewController 中。是委托人。
标签: ios uitableview uiviewcontroller frameworks didselectrowatindexpath