UIScrollView scroll not working after pushed with a navigation controller(使用导航控制器推送后 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 滚动不起作用


基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01