2

アプリにフォト ギャラリーがあります。複数の写真を選択して削除できます。すべてが順調に進んでいます。

カメラ ロールで確認できるように、Apple のデフォルトの選択動作を実装する必要があるだけです。

ここに画像の説明を入力

今の私の選択はこんな感じです

ここに画像の説明を入力

次のように didSelectItemAtIndexPath メソッドを実装しました-

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Delegate cell %@ : SELECTED", [self formatIndexPath:indexPath]);
    MyCustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    cell.label.backgroundColor=[UIColor greenColor];
}

 - (NSString *)formatIndexPath:(NSIndexPath *)indexPath 
{
    return [NSString stringWithFormat:@"%ld", (long)indexPath.row+1];
}

MyCustomCell.m では、図 (緑) に示すように、ラベルの枠を長方形に設定します。

メソッド setSelected は次のようになります。

- (void)setSelected:(BOOL)selected
{
    UIView *blurView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 70)];
    blurView.backgroundColor=[UIColor whiteColor];
    blurView.alpha=0.5;
    blurView.opaque=YES;
    if (selected) {
        self.label.backgroundColor = [UIColor greenColor];
        [self.imageThumb addSubview:blurView];
    }
}

それで、アップルのデフォルトの選択動作を持つことは可能ですか??

どんな助けでも大歓迎です。前もって感謝します。

4

2 に答える 2