Subview that is currently visible

Discussion in 'iOS Programming' started by xnakx, Oct 5, 2008.

  1. xnakx macrumors newbie

    Oct 5, 2008
    I have a UIScrollView with 5 UIImageViews (with unique tags) as subviews
    how do i get the tag of the UIImageView that is currently displayed?
    I am trying to update a UILabel's text to something like "Image x out of 5". from within scrollViewDidScroll

  2. xnakx thread starter macrumors newbie

    Oct 5, 2008
    found it.
    someone else pointed me to
    CGFloat pageWidth = scrollView.frame.size.width;
        int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    label.text=text = [NSString stringWithFormat:@"Image: %d",page];	

Share This Page