我有一個視圖,我在界面生成器中設置,我在IB中添加了一個scrollView,現在我試圖添加另一個scrollView,它將只是父scrollView的一部分。 旁邊的孩子滾動視圖我試圖使用動態大小的標籤,將居住在固定的標籤下。將scrollView添加到另一個scrollView不工作
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];
當我運行的應用程序的孩子不會被添加滾動視圖,也不是標籤?
任何幫助將不勝感激。
您是否驗證過所有變量都不是零? – Liron 2013-02-26 18:18:36
是的,一切似乎都沒問題。 – oridahan 2013-02-26 18:26:11
scrollView的框架是什麼? scrollView被添加到視圖中了嗎? – 2013-02-26 18:26:23