Seçilen UICollectionviewCell içinde dokunma konumunu almaya çalışıyorum. Görünüm olarak UICollectionView, collectionView içeren bir UIViewController var. CollectionView içinde UICollectionViewCells vardır. Vc, UICollectionViewDelegate
ile uyumludur, bu nedenle, tercihen delegenin geri çağrısına, collectionView:(UICollectionView *)collection didSelectItemAtIndexPath:(NSIndexPath *)indexPath
, (mümkünse) dokunulan yeri almak istiyorum. Bunu nasıl yapacağınız konusunda herhangi bir öneriniz var mı? Teşekkürler.uicollectionviewcell'in dokunmatik konumunu alma
+--------------------------------------------+
| UICollectionView |
| |
| +-------------+ +-------------+ |
| | UICollec | | | |
| | tionView | | | |
| | Cell | | *<---------------<Touch here
| | | | | |
| +-------------+ +-------------+ |
| |
+--------------------------------------------+
* UPDATE * I UIGestureRecognizer
kullanılarak UIViewCollectionView
hafifçe vurun tespit edilmesi ve daha sonra UICollectionViewCell
görünümüne musluk noktası dönüştürme sona erdi. Daha iyi bir yol varsa lütfen bana bildirin. Teşekkürler.
-(void) viewDidLoad {
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[tapGesture setNumberOfTapsRequired:1];
[self.collectionView addGestureRecognizer:tapGesture];
}
-(void) handleTap:(UIGestureRecognizer*) gesture {
if (gesture.state == UIGestureRecognizerStateEnded) {
CGPoint tappedPoint = [gesture locationInView:_collectionView];
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:tappedPoint];
CollectionViewCell *cell = (CollectionViewCell*)[self.collectionView cellForItemAtIndexPath:indexPath];
CGPoint pointWRTCell = [cell convertPoint:tappedPoint fromView:self.collectionView];
NSLog(@"collectionView point(%1.1f,%1.1f); cell point (%1.1f,%1.1f)",
tappedPoint.x,tappedPoint.y,pointWRTCell.x,pointWRTCell.y);
}
}
Yanıtınız için teşekkür ederiz. Alt sınıf 'UICollectionView' çalışabilir. Ben 'UITabGestureRecognizer' kullanarak sona erdi ve 'UICollectionView' dan 'UICollectionViewCell' – Loozie
'e dokunulan konumu dönüştürdüm Bazı içerikler daha iyi bir çözüm bulmamıza yardımcı olabilir. Çözmeye çalıştığın problem nedir? – CrimsonChris
Bir hücrenin belirli bir yerini (hücrenin kendisi değil) – Loozie