在集合视图上分享按钮

时间:2014-01-08 12:31:58

标签: ios uicollectionview

我已经看到了添加共享按钮的示例,但这些示例需要输入要共享的文件名,例如:[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];,如果在集合视图中使用不同的项目,如何实现?

1 个答案:

答案 0 :(得分:0)

  

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {       UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@“sampleCell”   forIndexPath:indexPath];

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom ];
[btn setImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]
     

forState:UIControlStateNormal];       btn.tag = indexPath.row;       [btn addTarget:self action:@selector(btn_Pressed)forControlEvents:UIControlEventTouchUpInside];

     

[cell.contentView addSubview:btn];   返回细胞; }

您可以通过其标签访问特定按钮...