Getting coordinates of UITableView live
I want to have a UIImageView follow the first cell down when scrol开发者_StackOverflowling down. So to do that, I thought I might try:
CGRect rect = [foldersTable convertRect:[foldersTable rectForRowAtIndexPath:indexPath2] toView:[foldersTable superview]];
imageView.frame=rect;
The problem is that the rect is not updating live as I scroll the table view. Where would I have to place the above code so that it updates as I scroll the table? Or am I missing anything else?
The correct way to do this is:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offset=foldersTable.contentOffset;
CGRect newFrame=CGRectMake(111, offset.y, 100, 100);
longRope.frame=newFrame;
}
This way it updates live as the scrollView in the tableView scrolls.
As UITableView inherits UIScrollView, check if contentOffset property can help to find how much you scrolled.
if its working then you can easily figure out rect if UIImageView with calculation.
If you need further details then post here......
精彩评论