テーブル全体ではなく、テーブルビューの特定の行/セルだけを拡大/縮小したいと思います。 私はピンチジェスチャーを使用していますが、その表のセルに作用していないので、テーブル全体で作業しています。テーブルビューの特定の1つのセルだけを拡大/縮小する方法は、テーブル全体ではありませんか?
私は一度に1つのセルをズームする必要がありますし、2番目のセルのセルをズームしたいときに、自動的にサイズを変更しますか?
私を助けてください。
ありがとうございます。
テーブル全体ではなく、テーブルビューの特定の行/セルだけを拡大/縮小したいと思います。 私はピンチジェスチャーを使用していますが、その表のセルに作用していないので、テーブル全体で作業しています。テーブルビューの特定の1つのセルだけを拡大/縮小する方法は、テーブル全体ではありませんか?
私は一度に1つのセルをズームする必要がありますし、2番目のセルのセルをズームしたいときに、自動的にサイズを変更しますか?
私を助けてください。
ありがとうございます。
次のコード試すことができます:あなたはdidSelectRowAtIndexPath
方法でこれを使用することができます
// For Zoom in
CGAffineTransform trans = CGAffineTransformScale(cell.contentView.transform, 100, 100);
view.transform = trans;
// For Zoom Out
CGAffineTransform trans = CGAffineTransformScale(cell.contentView.transform, 0.01, 0.01);
view.transform = trans;
を。選択cell
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
は今、あなたはcell
どこに? –
@ArchanaChaurasia:更新された回答を確認してください。 – Devang
しかし、私がcell.contentviewを取得する場所からdidSelectRowAtIndexPath? –
あなたは@Devangが
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
・ホープ内のコードに答え書いてみました持って取得するには、次のコードで
didSelectRowAtIndexPath:
の下で書き込みこれは役に立ちます。
変数
NSInteger今すぐ
あなたが/でセル をズームアウトするために、この方法を使用することができます- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //whatever your code write here if (selectedindex == indexPath.row) { [self animateZoomforCell:cell]; }else { [self animateZoomforCellremove:cell]; } return cell; } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //whatever your code write here selectedindex =indexPath.row; [self.tableView reloadData]; }
にこの事を置く
をselectedIndexの取ります
-(void)animateZoomforCell:(UITableViewCell*)zoomCell { [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ zoomCell.transform = CGAffineTransformMakeScale(1.6,1.6); } completion:^(BOOL finished){ }]; } -(void)animateZoomforCellremove:(UITableViewCell*)zoomCell { [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ zoomCell.transform = CGAffineTransformMakeScale(1.0,1.0); } completion:^(BOOL finished){ }]; }
あなたはそのようにそれを行うことができます。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self itemSelected:indexPath];
}
- (void)itemSelected:(NSIndexPath *)indexPath {
[UIView animateWithDuration:0.3 animations:^{
[self animate:indexPath highlighted:YES];
} completion:^(BOOL finished) {
[self animate:indexPath highlighted:NO];
}];
}
- (void)animate:(NSIndexPath *)indexPath highlighted:(BOOL)highlighted {
SoundEffectsCell *cell = (SoundEffectsCell *)[_collectionView cellForItemAtIndexPath:indexPath];
float scale = highlighted ? 0.9 : 1.0;
[UIView transitionWithView:_collectionView duration:0.1 options:UIViewAnimationOptionTransitionNone animations:^{
cell.transform = CGAffineTransformMakeScale(scale, scale);
} completion:nil];
}
あなたとCollectionViewCellを交換してください。 UICollectionViewで実装しましたが、UITableViewでも同じです。
私はあなたのquectを読んだ後にあなたの助けが必要です私はソリューションの同じタイプをしたい、ここでは特定のセルの代わりに私はズームしたいUIImageview助けてください注:ジェスチャーなしでそれは自動ズームする必要があります – Prashant09