如何在ios 7 xcode中单击scrollview上方的按钮时滚动滚动视图?

时间:2013-11-21 06:29:15

标签: ios iphone objective-c uiview

我有两个按钮。

滚动视图中还有两个屏幕,一个是UIView绿色,另一个是UIImage Apple徽标。两者都显示正常,但我只是采取这样的屏幕截图。

当我点击注册按钮然后在滚动视图中显示绿色视图的UIView

当我点击图片按钮时,它会显示UIImageView这是Apple徽标。 我拍摄的屏幕截图就像滚动视图滚动和绿色视图是uiview,第二个背后是包含图像的图像视图

 //help me

 -(IBAction)registrationClick:(id)sender
 {
    NSLog(@"mayank");
    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
    [self.scrollView scrollRectToVisible:frame animated:YES];
    pageControlBeingUsed = YES;
 }

enter image description here i take the screen shot like that the scrollview scroll and the green view is uiview and second behind it is image view that contain the image

1 个答案:

答案 0 :(得分:5)

[self.scrollView setContentOffset:CGPointZero animated:YES];

或者如果您想保留水平滚动位置并重置垂直位置:

[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0)
animated:YES];
相关问题