ios - 如何在 Objective C 的 UIScrollView 中禁用动画滚动?

标签 ios objective-c iphone xcode uiscrollview

我在 ScrollView 中加载了一个 pdf,我想直接转到下一页而不需要动画滚动。

CGRect scrollViewRect = CGRectInset(viewRect, -scrollViewOutset, 0.0f);

theScrollView = [[UIScrollView alloc] initWithFrame:scrollViewRect]; // All
theScrollView.autoresizesSubviews = NO;
theScrollView.contentMode = UIViewContentModeRedraw;
theScrollView.showsHorizontalScrollIndicator = NO; 
theScrollView.showsVerticalScrollIndicator = NO;
theScrollView.scrollsToTop = NO;
theScrollView.delaysContentTouches = NO;
theScrollView.pagingEnabled = YES;
theScrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
theScrollView.backgroundColor = [UIColor clearColor];
theScrollView.delegate = self;

[self.view addSubview:theScrollView];

这可能吗?

最佳答案

您必须使用以下方法通过以下方法跳转到下一页的直接偏移。

[objUIScrollView setContentOffset:CGPointMake(YOUR_X, YOUR_Y) animated:NO]

animated = NO;

如果您通过 WebView 加载 PDF,则需要遵循以下代码:

webview.scrollView.contentOffset = CGPointMake(YOUR_X, YOUR_Y);

Note : Use this above code in your Next Button page or after loading WebView properly may be in below method.

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
}

希望这会像您预期的那样工作。

关于ios - 如何在 Objective C 的 UIScrollView 中禁用动画滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41696518/

相关文章:

ios - 如何每次使用 AFNetworking 读取响应 header ?

objective-c - 有什么工具可以在 iOS 应用程序运行时生成对象图吗?

iphone - 我正在所有类中创建栏按钮。有没有办法只创建一次栏按钮并在所有类中使用它?

iphone - 切换 View 在 xcode 中不起作用

ios - 设置可选文本时,UIlabel 文本不显示 "optional"字?

ios - Xcode 找不到 openActiveSessionWithReadPermissions : FacebookSDK for iOS method

ios - 在 Swift 中对 @objc 类中的变量进行延迟初始化

iphone - 以编程方式加载 UIViewController? (OpenGL ES 2.0)

带有 Storyboard的 iOS 自定义键盘

iphone - 如何在 iPhone 上转换 wav 或 caf 音频文件