我不知道我做了什么,但我正在实现UIViewController Containment,突然之间UIKit UIScrollView子类停止了对滚动的响应,即使我绕过了所有自定义应用程序代码。例如,此标准设置代码。。。
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *vc = [[UIViewController alloc] init];
vc.view = [[UIView alloc] initWithFrame:self.window.frame];
UIScrollView *sv = [[UIScrollView alloc] initWithFrame:vc.view.frame];
sv.contentSize = CGSizeMake(400, 3000);
[vc.view addSubview:sv];
在一个全新的Xcode项目中,scrollView会滚动,但在我现有的项目中,滚动没有效果,滚动条也不会出现。两个项目中的AppDelegate代码完全相同,我唯一的#import是UIKit。
换句话说,我的应用程序中从UIScrollView继承的所有类突然表现得好像它们的scrollEnabled属性设置为NO,我无法更改这一点
它可能是界面生成器中滚动视图上的"启用滚动"属性。
// define the area that is initially visible
scrollViewCustom.frame = CGRectMake(0, 5, 354, 500);
// then define how much a user can scroll it
[scrollViewCustom setContentSize:CGSizeMake(354, 960)];
此外,清除滚动视图的背景色以显示文本。
scrollViewCustom.backgroundColor = [UIColor clearColor];
您可以像这样简单地创建。
scrollView=[[UIScrollView alloc]init]WithFrame:CGRectMake(0,0 ,320,480)];
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320, 600)];
scrollView.backgroundColor = [UIColor clearColor];
AFAIK这是由于糟糕的第三方代码使用了UIPanGestureRecognizers
而没有实现gestureRecognizerShouldBegin:
,从而覆盖了正常的滚动行为。