使用导航控制器推送后 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 滚动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

iOS refresh annotations on mapview(iOS在mapview上刷新注释)
How to calculate distance from user location to annotation when user moves(用户移动时如何计算用户位置到注释的距离)
In which case that mapView:viewForAnnotation: will be called?(在这种情况下 mapView:viewForAnnotation: 会被调用吗?)
NSTimeInterval to unix timestamp(NSTimeInterval 到 unix 时间戳)
How do I get a server timestamp from Firebase#39;s iOS API?(如何从 Firebase 的 iOS API 获取服务器时间戳?)
iOS Swift - Get the Current Local Time and Date Timestamp(iOS Swift - 获取当前本地时间和日期时间戳)