ios - 在 ios 7 xcode 中单击 ScrollView 上方的按钮时如何滚动 ScrollView ?

标签 ios iphone objective-c uiview

我有两个按钮。

我在 ScrollView 中也有两个屏幕,一个是绿色的 UIView,另一个是 UIImage Apple Logo 。两者都显示正常,但我只是这样截屏。

当我点击注册按钮然后在 ScrollView 中显示绿色 View 的UIView!

当我点击图像按钮时,它会显示 UIImageView,即 Apple Logo 。 我拍摄的屏幕截图是这样的, ScrollView 滚动,绿色 View 是 uiview,第二个是包含图像的 ImageView

 //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

最佳答案

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

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

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

关于ios - 在 ios 7 xcode 中单击 ScrollView 上方的按钮时如何滚动 ScrollView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20113990/

相关文章:

objective-c - 按自定义对象的子对象属性对数组进行排序?

ios - UIView动画交互

ios - Objective-c shouldRecognizeSimultaneouslyWithGestureRecognizer 禁用其他GestureRecognizer

iphone - 如何在 iOS 上捕获的视频中添加水印

ios - 如何根据 UITableView 中的文本增加 UILabel 高度?

c++ - 在 Objective-C 中使用外部 C++ 头文件

ios - 如何在 Swift 中将文本字段的值传递给单击按钮的函数?

iphone - 检查 bundle 中是否存在图像 - iPhone

iphone - 如何让用户通过 iPhone 上的 Facebook Connect 成为某个页面的粉丝

iphone - xcode4 不支持 Perforce?