我有一个在界面生成器中设置的视图,我在 IB 中添加了一个滚动视图,现在我正在尝试添加另一个滚动视图,它只是父滚动视图的一部分。在子滚动视图上,我正在尝试使用一个动态大小的标签,该标签将驻留在另一个固定标签下。
UIScrollView *ingredientsScrollView = [[UIScrollView alloc]
initWithFrame:CGRectMake(20, 287, 280, 300)];
ingredientsScrollView.scrollEnabled = YES;
UILabel *ingredientsLabel = [[UILabel alloc] initWithFrame:CGRectMake(230, 310, 70, 21)];
ingredientsLabel.text = @"מצרכים";
UILabel *baseLabel = [[UILabel alloc] initWithFrame:CGRectMake(230, 325, 70, 21)];
baseLabel.text = @"חומרים לבסיס";
UILabel *baseIngredientsLabel = [[UILabel alloc] init];
CGSize maximumLabelSize = CGSizeMake(296,9999);
CGSize expectedLabelSize = [baseIngredientsString sizeWithFont:baseIngredientsLabel.font
constrainedToSize:maximumLabelSize
lineBreakMode:baseIngredientsLabel.lineBreakMode];
//adjust the label the new height.
CGRect newFrame = baseIngredientsLabel.frame;
newFrame.size.height = expectedLabelSize.height;
baseIngredientsLabel.frame = newFrame;
//i added text to the string in some way
baseIngredientsLabel.text = baseIngredientsString;
[ingredientsScrollView addSubview:ingredientsLabel];
[ingredientsScrollView addSubview:baseIngredientsLabel];
[scrollView addSubview:ingredientsScrollView];
当我运行应用程序时,没有添加子滚动视图,也没有添加标签?
任何帮助将不胜感激。