This was a different question but what I thought was wrong was not wrong so I adjusted the title to reflect what I really figured out.
I am working on an animation that takes a copy of an image in the cell.imageView of a normal UITableViewCell and moves it to the tab bar on the bottom of screen, to simulate putting an item in a cart. I can copy the image and place the copy as a subview of the window, but I can't figure out how to get the absolute position of the original image so I can place it on top as the starting point of my animation.
The image always shows up at the top of the screen as if placed at 0,0.
Sorry for the noobish nature of the question, I'm sure i'm missing something very obvious.
-(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
}