2014-01-08 36 views
0

我見過添加分享按鈕的例子,但這些例子需要輸入要共享的文件名,例如:[controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];,使用集合視圖中的不同項目時如何實現?收藏視圖上的分享按鈕

回答

0

- (UICollectionViewCell *)的CollectionView:(UICollectionView *)的CollectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *細胞= [的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]; return cell; }

您可以通過其標籤訪問特定按鈕...