[英]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.