[英]How can I assign a view to a controller on iPhone?
If I have a UIView, called " someView", than, I have a controller, which is called "myController". 如果我有一个名为“ someView”的UIView,那么我有一个名为“ myController”的控制器。 I want to assign the someView with myController, how can I do so in code? 我想用myController分配someView,如何在代码中这样做? Thank you. 谢谢。
Basically: 基本上:
Read what @Lou Franco suggests. 阅读@Lou Franco的建议。
Implement the load view like that: 像这样实现加载视图:
- (void)loadView {
[super loadView];
MyCustomView *view = [[MyCustomView alloc] initWithFrame:self.view.frame];
self.view = view;
[view release];
// Setup other views if needed
}
From: 从:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html
If you specify the views manually, you must implement the loadView method and use it to assign a root view object to the view property. 如果手动指定视图,则必须实现loadView方法并将其用于将根视图对象分配给view属性。
Read about loadView here: 在此处阅读有关loadView的信息:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/loadView http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/loadView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.