小编Don*_*onk的帖子

访问现有的UITableViewCell

这是一个不同的问题,但我认为错误并没有错,所以我调整了标题以反映我真正想到的.

我正在制作一个动画,它在普通UITableViewCell的cell.imageView中获取一个图像的副本,并将其移动到屏幕底部的标签栏,以模拟将项目放入购物车.我可以复制图像并将副本作为窗口的子视图放置,但我无法弄清楚如何获得原始图像的绝对位置,因此我可以将它放在顶部作为动画的起点.

图像始终显示在屏幕顶部,就像放在0,0一样.

对不起这个问题的noobish性质,我敢肯定我错过了一些非常明显的东西.

- (void)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
Run Code Online (Sandbox Code Playgroud)

}

animation uitableview coordinates uiview ios

3
推荐指数
1
解决办法
1147
查看次数

标签 统计

animation ×1

coordinates ×1

ios ×1

uitableview ×1

uiview ×1