Manish Jain
Manish Jain

Reputation: 865

UIScrollview paging like animation

I have a view that have some images, text, and more to show and two button in left and right when user click on left or righr button page should get side and another page should get open with new info.

How i can do it please help.enter image description here

Upvotes: 1

Views: 1298

Answers (3)

Harish Patidar
Harish Patidar

Reputation: 53

Use this code

-(IBAction)prevButtonPage:(id) sender 
{ 

    CGFloat xOffset = pagingScrollView.contentOffset.x;
    CGFloat yOffset = pagingScrollView.contentOffset.y;

    if (pagingScrollView.contentOffset.x != pagingScrollView.frame.origin.x)
    {
        [pagingScrollView setContentOffset:CGPointMake(xOffset- 320, yOffset) animated:YES];
        // [arrayIndia objectAtIndex:i];
    }

    NSLog(@" custom  x==%f %f", pagingScrollView.contentOffset.x, pagingScrollView.contentSize.width);

}

-(IBAction)nextButtonPage:(id) sender 
{ 

    CGFloat xOffset = pagingScrollView.contentOffset.x;
    CGFloat yOffset = pagingScrollView.contentOffset.y;

    if ((pagingScrollView.contentOffset.x != pagingScrollView.frame.origin.x)&&(pagingScrollView.contentOffset.x !=[imageArray count]) )
    {
        [pagingScrollView setContentOffset:CGPointMake(xOffset + 320, yOffset) animated:YES];

    }
    NSLog(@" custom  x==%f %f", pagingScrollView.contentOffset.x, pagingScrollView.contentSize.width);

}

Upvotes: 0

silviupop
silviupop

Reputation: 648

Enable paging for the scrollview.

When a button is tapped modify the content offset of the scrollview by the width of the scrollview using setContentOffset:animated:

Upvotes: 1

Anand
Anand

Reputation: 1983

try with this link.. You will get the logic to solve your problem. Place a button on each side where you want & use the logic from this thread

Upvotes: 1

Related Questions