【问题标题】:How can i scroll the scrollview when click on button above scrollview in ios 7 xcode?在ios 7 xcode中单击滚动视图上方的按钮时,如何滚动滚动视图?
【发布时间】:2013-11-21 06:29:14
【问题描述】:

我有两个按钮。

我在滚动视图中也有两个屏幕,一个是绿色的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;
 }

【问题讨论】:

  • 我想添加图像,但它给了我一个错误,比如需要 10 重新布线等......
  • 朋友通过点赞帮助他。我给 +1
  • 现在可以添加图片了。
  • 请回答我...我在注册按钮和图像按钮方法中写了什么...并且还请定义我需要的其他方法或代码

标签: ios iphone objective-c uiview


【解决方案1】:
[self.scrollView setContentOffset:CGPointZero animated:YES];

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-27
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    • 1970-01-01
    • 2012-11-27
    相关资源
    最近更新 更多