简体   繁体   English

navigationController.pushViewController方法返回未定义

[英]navigationController.pushViewController the method returns undefined

Here I have a problem with the pushController because I want to use da, s my subclass like this 在这里,pushController存在问题,因为我想使用da s这样的子类

class cellEmpty < cell

    @button_help.when(UIControlEventTouchUpInside) do
      push RecommendationController.alloc.init
    end

 def push(controller)
    navigationController.pushViewController(controller, animated:true)
  end
end

Here the error : 这里的错误:

undefined local variable or method `navigationController'

but me, so I think it must be that I use it in a subclass. 但是我,所以我认为一定是我在子类中使用它。 but how to use it 但是如何使用

thank you in advance 先感谢您

You're getting this error because the method is being called from within a UICell. 您正在收到此错误,因为该方法是在UICell中调用的。 You'll need to call this method from with your view controller to get access to the navigationController. 您需要使用视图控制器从中调用此方法,才能访问navigationController。

If you're using a UITableViewController take a look at this method: 如果您使用的是UITableViewController,请查看以下方法:

tableView(tableView, didSelectRowAtIndexPath: indexPath)

From there you can determine what to do when someone taps on a cell. 在这里,您可以确定当有人点击单元格时该怎么办。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NavigationController.PushViewController也会移动导航栏 - NavigationController.PushViewController moves the navigation bar as well 如何在UITableViewSource下访问NavigationController.PushViewController? - How to access NavigationController.PushViewController under UITableViewSource? MonoTouch: UITableViewController,NavigationController 在 NavigationController.PushViewController 之后是 null - MonoTouch: UITableViewController,NavigationController is null after NavigationController.PushViewController 如果在mainQueue / mainThread之外运行,NavigationController.pushViewController崩溃 - NavigationController.pushViewController crashes if run outside of mainQueue/mainThread navigationController.pushViewController 似乎在 Xcode 11 中不起作用? - navigationController.pushViewController doesn't seem to work in Xcode 11? TableViewController的pushViewController方法(导航)中的navigationController = null - navigationController = null in TableViewController's pushViewController method (popover) iOS NavigationController pushViewController不起作用 - iOS navigationController pushViewController not working 没有导航控制器的 pushViewController - pushViewController without navigationcontroller UIPageViewController中的navigationController pushViewController不起作用 - navigationController pushViewController from UIPageViewController not work navigationController..pushViewController无法启动视图 - navigationController?.pushViewController fails to launch the view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM