0
votes

I have a scrollview where I have added different views (like tutorial).

enter image description here

What I wanted to have is slider with below design where on scroll I will see previous tut on left side and next on right side.

For this what I have added is scrollview with paging enabled and adding UILabel (for now) in for loop. After adding label in scrollview below is what I had.

enter image description here

To see the data on the left & right, what I did is uncheck clip subviews from storyboard.

enter image description here

However what I noticed is I can scroll only in scrollview area and not outside.

Any idea how can I make UILabel make scrolling outside & inside scrollview.


As of now to make it working, what I have done is added swipe gesture on view and making scrolling programmatically. However what I was looking is if I scroll outside scrollview, it should scroll scrollview little too.

1
i m not clear on this However what I was looking is if I scroll, it should scroll little - Anbu.Karthik
@Anbu.Karthik : means if I scroll left, gesture is getting called and its swiping scrollview however I want to scroll as I move finger... - Fahim Parkar
@Anbu.Karthik : checkout the solution - Fahim Parkar

1 Answers

1
votes

Phewww...

Finally I managed to make it done..

What I did is added one more scrollview (dummyScrollView) with full screen width above main scrollview (mainScrollView) (which I am using to show label).

Now I enabled paging for the dummyScrollView too and implement below where I am scrolling my mainScrollView based on the factor calculation for the dummyScrollView

#pragma mark - UIScrollView Delegate
- (void) scrollViewDidScroll:(UIScrollView *)sender
{

    float myFactor = 0;
    // 44232 is tag for new scrollview
    if (sender.tag==44232) {

        myFactor = mainScrollView.frame.size.width/duplicateSV.frame.size.width;

        myFactor = duplicateSV.contentOffset.x*myFac;

        CGRect mCC = CGRectMake(myFactor, 0, mainScrollView.frame.size.width, mainScrollView.frame.size.height);
        [mainScrollView scrollRectToVisible:mCC animated:NO]; // NO is very important... YES will not work
    }

    // 44231 is main scrollview tag where I won't be doing anything...
    if (sender.tag==44231) {

    }
}