这是一个不同的问题,但我认为是错误的没有错,所以我调整了标题以反映我真正想到的。访问现有的UITableViewCell
我正在处理一个动画,它需要在正常的UITableViewCell的cell.imageView中将图像的副本移动到屏幕底部的选项卡栏上,以模拟将物品放入购物车。我可以复制图像并将副本作为窗口的子视图,但我无法弄清楚如何获得原始图像的绝对位置,以便将它放在顶部作为动画的起点。
图像始终显示在屏幕的顶部,好像置于0,0一样。
对不起,这个问题没有问题,我相信我错过了一些非常明显的东西。
- (空)的tableView:(UITableView的 *)的tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]; UIImageView *originalImgView = cell.imageView; UIImageView *img = [[[UIImageView alloc] initWithImage: cell.imageView.image] autorelease]; NSLog(@"Original %@", originalImgView.bounds); // Shows "Original (null)" at runtime. NSLog(@"Window Points %@", [self.view.window convertPoint:originalImgView.frame.origin toView:nil]); NSLog(@"Cell Points: %@", cell.bounds); // Shows "Original (null)" at runtime. [img setFrame:CGRectMake(originalImgView.bounds.origin.x, originalImgView.bounds.origin.y , cell.imageView.image.size.width, cell.imageView.image.size.height)]; [self.view.window addSubview:img]; NSLog(@"Selected Cell: %@", cell); // Shows cell info at run time, works
}
我想我想通了。当我调用[自我tableView:tableView cellForRotAtIndexPath ....]。我没有获得对现有单元格的参考。我从头开始获得一个新的“复制”单元。所以当我试图获得关于细胞位置的信息时,我实际上已经获得了我的细胞拷贝的位置,这个位置还没有正确铺设。 – Donk 2011-02-25 01:31:14