How to set UiScrollView Frame when clicking UIButton in Iphone?

I have a UIScrollView on which I use 2 UIButtons. The start frame of the UIScrollView (0.0768.1024). I want the UIScrollView y-cordinate position to be 500 by clicking on the first button, which means that it will close 500 positions below its actual position.

And when I press the second button that will be displayed in the UIScrollView, position the Y-cordinate UIScrollView y = 535, the UIScrollView will again move to the y = 0 position.

First, click the UIScrollView y = 500 button. The second button is UIScrollView y = 0

Any tips from experts would be very welcome.

+5
source share
2 answers

It can solve ur pbm

-(IBAction) clickfirstbutton 
{
   [scrollview setContentOffset:CGPointMake(0, 500)) animated:TRUE];
}

-(IBAction) clicksecondbutton
{
   [scrollview setContentOffset:CGPointMake(0, 0) animated:TRUE];
}

,

[scrollview setContentOffset:CGPointMake(0, 0) animated:FALSE];
0

, frame ( ), contentOffset. .

CGPoint offset = scrollView.contentOffset;
offset.y += 500;
[scrollView setContentOffset:offset animated:YES];
+2

All Articles