我完全失去了superview,loadView(),viewDidLoad(),viewWillAppear()。最终,我想将我的控制器的框架设置为superview的边界,并在我的viewDidLoad()中使用[self.view bounds]。 (也许这是不可能的?)如何以编程方式创建视图并根据超级视图设置其框架? (iphone)
这里的代码片段,让我的悲伤..
// 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).
}
显然,零== controller.view.superview调用控制器的viewDidLoad。
我曾经访问[self.view界限],如果加上它的SuperView后使用我的viewDidLoad
内因为我想设置视图的框架,我想我需要移动使用[self.view范围代码]到别的地方。
转移到什么地方? 还是有更好的方法?
啊谢谢,应该是controller.view,我搞砸了。我编辑了我的问题。总之,我可以使用它的超级视图来设置视图的框架,并在viewDidLoad被调用的时候使用[self.view bounds]? – eugene 2010-11-09 11:17:11