使用导航控制器推送后 UIScrollView 滚动不起作用

UIScrollView scroll not working after pushed with a navigation controller(使用导航控制器推送后 UIScrollView 滚动不起作用)

本文介绍了使用导航控制器推送后 UIScrollView 滚动不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题.我在视图层次结构的一部分中有一个 UIScrollView .当视图通过 UITabBarController 呈现时,它工作得很好,但在使用导航控制器推送后根本不起作用(它是第三个 vc 推送到根顶部).滚动视图是在情节提要中创建的,以下几行在 viewDidAppear 方法中:

I'm having an odd problem. I have a UIScrollView in a part of view hierarchy. It's working just fine when the view is presented via UITabBarController, but doesn't work at all after it is pushed with a Navigation controller (it is the third vc pushed atop the root). The scroll view was created in storyboard and the following lines are in the viewDidAppear method:

[super viewDidAppear:animated];
[self.scrollView setScrollEnabled:YES];
self.scrollView.contentSize = CGSizeMake(320.0f, 468.0f);

有什么想法或建议吗?如果您需要滚动视图属性检查器的照片,请告诉我.下面是调用方法.错误可能在这里的某个地方.

Any ideas, or suggestions? If you need shots of scrollview attributes inspector let me know. Here's the call method. The error might be somewhere inside here.

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone"
                                                 bundle:nil];
    MKontaktViewController *vc = [sb instantiateViewControllerWithIdentifier:@"Kontakt"];
    vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self.navigationController pushViewController:vc
                                         animated:YES];

谢谢,丘吉尔

推荐答案

如果你在 viewDidLayoutSubview 函数中调整滚动视图内容的大小,它会再次起作用.

If you resize the scroll view content size in the viewDidLayoutSubview function it will work again.

- (void) viewDidLayoutSubviews {
    [self resizeScrollViewContent];
}


这里有同样的问题

这篇关于使用导航控制器推送后 UIScrollView 滚动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用导航控制器推送后 UIScrollView 滚动不起作用

基础教程推荐