Dan*_*ter 10 xcode objective-c ios uicollectionview uicollectionviewcell
是否有可能将UICollectionViewCell's
坐标从相对于UICollectionView
相对于相对于superview
?的坐标转换为?到目前为止,我一直无法UICollectionViewCell's
在触摸时转换坐标superview
.这是我到目前为止所尝试的:
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell"
forIndexPath:indexPath];
CGRect frame = CGRectMake(0.0,
0.0,
cell.frame.size.width,
cell.frame.size.height);
frame.origin = [cell convertPoint:cell.frame.origin
toView:self.view];
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个新的框架,它起源于单元格在视图上的位置,而不是在视图中UICollectionView
.任何帮助都会非常感谢.
小智 35
这个答案很晚,但希望它会对某人有所帮助.丹,你有正确的想法,但你拥有的东西更容易.只需更换
CGRect frame = CGRectMake(0.0, 0.0, cell.frame.size.width, cell.frame.size.height);
frame.origin = [cell convertPoint:cell.frame.origin toView:self.view];
Run Code Online (Sandbox Code Playgroud)
同
CGRect frame = [collectionView convertRect:cell.frame toView:self.view];
Run Code Online (Sandbox Code Playgroud)
问题是你在单元格上调用convert方法,而不是collectionView.
归档时间: |
|
查看次数: |
10789 次 |
最近记录: |