【发布时间】:2014-06-11 10:47:42
【问题描述】:
我正在以编程方式将自定义视图添加到情节提要中定义的另一个视图,但是当我返回此视图时,自定义视图消失了。
仅当从 Storyboard segues 回来时才会发生这种情况,当我以编程方式推送视图并返回时,它不会消失。
此外,它仅在 iOS 7 上发生。iOS 6 很好。
在此先感谢大家。
collectionView.frame = CGRectMake(collectionView.frame.origin.x, collectionView.frame.origin.y, collectionView.frame.size.width, collectionView.frame.size.height - ADROTATORHEIGHT);
CGFloat width = self.view.frame.size.width;
CGFloat x = self.view.frame.origin.x;
CGFloat y = self.view.frame.size.height - ADROTATORHEIGHT;
adHolder.frame = CGRectMake(x, y, width, ADROTATORHEIGHT);
adHolder.backgroundColor = [UIColor whiteColor];
[adHolder addSubview:adViewController.view];
[self.view addSubview:adHolder];
[collectionView reloadData];
【问题讨论】:
-
@David 此代码位于应用程序启动时从 Storyboard 加载的第一个视图控制器 (viewDidLoad) 中。