【问题标题】:Simulate didSelectRowAtIndexPath with a UIButton in a customized UITableViewCell在自定义 UITableViewCell 中使用 UIButton 模拟 didSelectRowAtIndexPath
【发布时间】:2011-10-12 07:22:16
【问题描述】:

我在自定义 UITableViewCell 中有一个 UIButton,它是 UITableViewCell 的子类。

UIButton 在 IB 中是 IBOutlet-ed,而 IBAction-ed 是一个函数:

- (IBAction)clickRead:(id)sender;

现在,当我单击按钮时,按钮没有响应,因为函数内部没有任何内容。我应该在函数中写什么,以便 UIButton 可以模拟 tableView 的didSelectRowAtIndexPath 函数(即选择表格单元格)?

【问题讨论】:

  • 您的意思是当您单击任何一行的按钮时应该选择该行?
  • 是的!如果单击该行上的按钮,则应选择该行并调用函数 didSelectAtIndexPath。

标签: uitableview


【解决方案1】:

这个答案可能会有所帮助:hitting a next button for a UITableViewcell

您可以调用 UITableView selectRowAtIndexPath:animated:scrollPosition: 以直观地选择行,但您仍然需要自己管理任何事件:加载另一个视图、调用 didSelectRowAtIndexPath:、故事板转场等。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    相关资源
    最近更新 更多