我完全迷失了 superview、loadView()、viewDidLoad()、viewWillAppear()。
最终,我想将控制器的框架设置为超级视图的边界,并在我的 viewDidLoad() 中使用 [self.view bounds]。(也许这是不可能的?)
这是让我悲伤的代码片段..
// add the controller's view to the scroll view
if (nil == controller.view.superview) {
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
// I'd like to set controller.view 's frame using superview(scrollView here).
}
显然,nil == controller.view.superview 调用了控制器的 viewDidLoad。
我曾经访问 [self.view bounds] 并在我的 viewDidLoad 中使用它
由于我想在将其添加到 superview 后设置视图的框架,我想我需要将利用 [self.view bounds] 的代码移动到其他地方。
什么地方适合搬家?还是有更好的方法?