【问题标题】:how to design uicollectionviewcell's pushing depends on cell type?如何设计uicollectionviewcell的推送取决于单元格类型?
【发布时间】:2013-11-01 15:40:25
【问题描述】:

美好的一天!我有 uicollectionview,在单元格中显示不同的文档...是否可以根据单元格(文档)类型设计推送单元格并显示不同的视图控制器?

【问题讨论】:

  • “设计推动单元”是什么意思?
  • 感谢您的回答=) 这意味着不使用代码,我应该分析用户选择的单元格类型,然后为该单元格选择笔尖,但在跳板上设计它=)
  • 您能否为您的问题添加更多描述?通过在跳板上设计它是指界面构建器/故事板?
  • 是的)我的意思是为 IB 中的 nib 设计所有故事板转场......

标签: push uicollectionview uicollectionviewcell springboard


【解决方案1】:

假设您的UICollectionViewCell 知道它应该显示哪个文档,您可以在离开视图后使用该信息来区分文档。按住 Control 从您的单元格拖动到 Interface Builder 中的新视图控制器,并在 prepareForSegue 中实现区别

-(void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender {
   if ([segue.identifier isEqualToString:@"ShowDetailController"]) {
        MyDetailViewController *destination = segue.destinationViewController;
        UICollectionViewCell *cell = (UICollectionViewCell*)sender;
        // depending on your cell implementation, e.g. with an enum
        destination.documentType = cell.documentType;
   }
}

【讨论】:

  • 所以在故事板中设计不同的推送是不可能的...... Mundi 的真实代码允许控制视图控制器的填充。那就是模式工厂=)
  • 有可能。但以上是可取的。
猜你喜欢
  • 2015-06-22
  • 2018-11-30
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多