iOS超级怪异的问题,添加了子视图,而无需添加我

||| 我有一个UIScrollView,向其中添加了几个子视图(在
loadView
中完成)(请参见代码):
// Add the views to the Scroll View
[scrollView addSubview:label];
[scrollView addSubview:careerDescriptionWebView];

self.view = scrollView;
然后,我稍后要计算添加的子视图的高度(在
viewWillAppear:
中完成以设置UIScrollView的高度(请参见以下代码):
// Change the height of the Scroll View dynamically to match the content
float hgt = 0; 

for (UIView *view in scrollView.subviews) {
    hgt += view.frame.size.height;
    NSLog(@\"View: %@, height: %f\", [[view class] description], view.frame.size.height);
}    

[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width,hgt)];
因此,稍后检查控制台的输出时,会看到以下内容:
2011-06-23 13:34:48.344 Acando[90355:207] View: UILabel, height: 21.000000
2011-06-23 13:34:48.345 Acando[90355:207] View: UIWebView, height: 1017.000000
2011-06-23 13:34:48.346 Acando[90355:207] View: UIImageView, height: 7.000000
2011-06-23 13:34:48.347 Acando[90355:207] View: UIImageView, height: 145.000000
它不会立即出现,起初它只能通过UILabel和UIWebView正确显示,它在加载视图控制器两次后似乎随机出现。     
已邀请:
        这是因为scrollview在此视图中还有2件事,一个是水平滚动条,第二个是垂直滚动条,当您上下左右滚动时会自动显示     

要回复问题请先登录注册