使用导航控制器推动后,UIScrollView滚动不起作用 [英] UIScrollView scroll not working after pushed with a navigation controller

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

问题描述

我有一个奇怪的问题.我在视图层次结构的一部分中有一个UIScrollView.当通过UITabBarController呈现视图时,它工作得很好,但是在使用Navigation控制器将视图推入视图后,它根本不起作用(这是将第三个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滚动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆