获取collectionViewcCell及tableViewCell在当前屏幕的位置大小
来源:互联网 发布:千百撸最新域名获取器 编辑:程序博客网 时间:2024/06/05 10:40
● 获取collectionViewcCell在当前屏幕的位置大小
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
//临时改变个颜色,看好,只是临时改变的。如果要永久改变,可以先改数据源,然后在cellForItemAtIndexPath中控制。(和UITableView差不多吧!O(∩_∩)O~)
// cell.backgroundColor = [UIColor greenColor];
// NSLog(@"item======%ld",(long)indexPath.item);
// NSLog(@"row=======%ld",(long)indexPath.row);
// NSLog(@"section===%ld",(long)indexPath.section);
// NSLog(@"123456789--%f",cell.bounds.size.height);
/*
获取当前点击的cell位置大小,以此设定view2初始大小和位置
*/
//cell在当前collection的位置
CGRect cellRect = [_collectionView convertRect:cell.frame toView:_collectionView];
NSLog(@"987654321- %f - %f # %f - %f",cellRect.origin.x,cellRect.origin.y,cellRect.size.width,cellRect.size.height);
//cell在当前屏幕的位置
CGRect rect2 = [_collectionView convertRect:cellRect toView:self.view];
NSLog(@"987654321- %f - %f # %f - %f",rect2.origin.x,rect2.origin.y,rect2.size.width,rect2.size.height);
}
● 获取tableViewcCell在当前屏幕的位置大小
CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
CGRect rect = [tableView convertRect:rectInTableView toView:[tableView superview]];
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
//临时改变个颜色,看好,只是临时改变的。如果要永久改变,可以先改数据源,然后在cellForItemAtIndexPath中控制。(和UITableView差不多吧!O(∩_∩)O~)
// cell.backgroundColor = [UIColor greenColor];
// NSLog(@"item======%ld",(long)indexPath.item);
// NSLog(@"row=======%ld",(long)indexPath.row);
// NSLog(@"section===%ld",(long)indexPath.section);
// NSLog(@"123456789--%f",cell.bounds.size.height);
/*
获取当前点击的cell位置大小,以此设定view2初始大小和位置
*/
//cell在当前collection的位置
CGRect cellRect = [_collectionView convertRect:cell.frame toView:_collectionView];
NSLog(@"987654321- %f - %f # %f - %f",cellRect.origin.x,cellRect.origin.y,cellRect.size.width,cellRect.size.height);
//cell在当前屏幕的位置
CGRect rect2 = [_collectionView convertRect:cellRect toView:self.view];
NSLog(@"987654321- %f - %f # %f - %f",rect2.origin.x,rect2.origin.y,rect2.size.width,rect2.size.height);
}
● 获取tableViewcCell在当前屏幕的位置大小
CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
CGRect rect = [tableView convertRect:rectInTableView toView:[tableView superview]];
0 0
- 获取collectionViewcCell及tableViewCell在当前屏幕的位置大小
- 获取tableviewCell在当前屏幕中的坐标值
- 获取tableviewCell在当前屏幕中的坐标值
- 获取tableviewCell在当前屏幕中的坐标值
- devexpress gridView获取当前单元格在屏幕上的位置
- iOS开发- 根据表格点击tableviewCell获取在当前屏幕中的坐标值
- C#获取当前屏幕大小或任务栏的大小
- 获取屏幕位置、高度和在屏幕上的位置
- c#获取当前屏幕大小
- Javascript获取窗口的大小及位置
- 获取鼠标在屏幕的位置
- 获取tableViewCell点击的位置和indexPath
- 如何获取当前设备的屏幕的大小初始化UIWindow
- Robotium测试之——获取当前屏幕的大小
- Robotium测试之——获取当前屏幕的大小
- Robotium测试之——获取当前屏幕的大小
- Android中获取当前屏幕的尺寸大小
- javascript 对屏幕位置及浏览器位置的获取
- sftp命令的简单用法
- 本地推送和远程通知
- QSignalMapper
- 【JAVA】给大家推荐一道有意思的java测试题。你知道答案吗?
- MFC多线程的创建,包括工作线程和用户界面线程
- 获取collectionViewcCell及tableViewCell在当前屏幕的位置大小
- background img div 撑开父类内容 图片不能显示
- 378. Kth Smallest Element in a Sorted Matrix
- SVN使用教程总结
- 图象处理基本算法[整理] 转自:农夫三拳
- sycchronized 同步锁
- Windows 8.1内核利用—CVE-2014-4113漏洞分析
- 【三星官方教程】如何为Gear VR开发应用(五):添加功能
- JUnit + Mockito 单元测试