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正确显示,它在加载视图控制器两次后似乎随机出现。
没有找到相关结果
已邀请:
1 个回复
款去芳尾脊