开发者

Getting coordinates of UITableView live

开发者 https://www.devze.com 2023-04-02 01:27 出处:网络
I want to have a UIImageView follow the first cell down when scrol开发者_StackOverflowling down. So to do that, I thought I might try:

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......

0

精彩评论

暂无评论...
验证码 换一张
取 消