Ios 将UIScrollView添加到UIView时无法滚动

Ios 将UIScrollView添加到UIView时无法滚动,ios,objective-c,Ios,Objective C,我试图在UIView中添加一个scrollview,并在其上添加标签、文本视图和图像,但滚动条不显示,我无法滚动 //faux view UIView* fauxView = [[[UIView alloc] initWithFrame: CGRectMake(10, 10, 200, 200)]autorelease] ; [self.bgView addSubview: fauxView]; //the new panel self.bigPanelView = [[[UIView

我试图在UIView中添加一个scrollview,并在其上添加标签、文本视图和图像,但滚动条不显示,我无法滚动

    //faux view
UIView* fauxView = [[[UIView alloc] initWithFrame: CGRectMake(10, 10, 200, 200)]autorelease] ;
[self.bgView addSubview: fauxView];

//the new panel
self.bigPanelView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bgView.frame.size.width, self.bgView.frame.size.height)]autorelease];
self.bigPanelView.center = CGPointMake( self.bgView.frame.size.width/2, self.bgView.frame.size.height/2);
self.bigPanelView.backgroundColor = self.initialBackgroundColor;


UIScrollView * scroll = [[UIScrollView alloc] initWithFrame:self.bigPanelView.bounds];
[scroll setContentSize:CGSizeMake(200, 200)];
[self.bigPanelView addSubview:scroll];
scroll.showsVerticalScrollIndicator = YES;



// add label

UILabel *lblTitle = [[[UILabel alloc] initWithFrame:CGRectMake(0, 25, self.bgView.frame.size.width, 46)]autorelease]; 
// If I change the 25 to 235 the label will come under the screen but still I cannot    scroll.
lblTitle.textAlignment = NSTextAlignmentCenter; // Align the label text in the center
lblTitle.backgroundColor = [UIColor clearColor];
lblTitle.text = self.initialTitle;
lblTitle.textColor = self.initialTitleColor;
lblTitle.font = [UIFont systemFontOfSize:31];
[scroll addSubview: lblTitle]; 

对于滚动-滚动视图内容大小应大于滚动视图框架。

对于滚动-滚动视图内容大小应大于滚动视图框架。

您必须使滚动视图的
内容大小大于视图:

[scroll setContentSize:CGSizeMake(200, 200)];
需要类似于:

[scroll setContentSize:CGSizeMake(400, 400)];

当然,要使滚动视图的内容大小与您要放置的内容大小相同,这样,它只有在需要时才会滚动。

您必须使滚动视图的
contentSize
大于视图:

[scroll setContentSize:CGSizeMake(200, 200)];
需要类似于:

[scroll setContentSize:CGSizeMake(400, 400)];

当然,将其设置为要在滚动视图中显示的内容的大小,这样,它只在需要时滚动。

我尝试过将其设置为400400,但我仍然无法垂直滚动,水平滚动有效。我尝试过将其设置为400400,但仍然无法垂直滚动,水平卷轴可以工作。