【问题标题】:in rubymotion how to manually invoke table method在rubymotion中如何手动调用表方法
【发布时间】:2014-11-19 11:03:40
【问题描述】:

我正在使用 UICollectionViewController 并尝试将项目设置为自动选择(即先前选择的选项)。如果我在设置单元格数据时尝试设置

def collectionView(view, cellForItemAtIndexPath: index_path)  

  //create the cell etc.. then
  cell.selected = true
  cell.update(index_path.row)
end

我得到 NoMethodError 选择。但是,这适用于正常的选择/取消选择方法。

  def collectionView(view, didSelectItemAtIndexPath: index_path)
  cell = view.cellForItemAtIndexPath(index_path)
  cell.selected = true     
end

关于如何自动预选单元格的任何想法?

谢谢,

【问题讨论】:

    标签: rubymotion


    【解决方案1】:

    要在名为myColView 的集合视图中预先选择一个单元格,请调用:

    indexPath = NSIndexPath.indexPathForItem(1, inSection: 0)
    myColView.selectItemAtIndexPath(indexPath, animated: false, scrollPosition: 0)
    

    此方法不会导致调用任何与选择相关的委托方法。

    【讨论】:

    • 太棒了!感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多