【发布时间】:2011-10-04 19:26:42
【问题描述】:
例如,我的 uiviewcontroller 中有这个
- (void)loadView {
CGRect frame = [[UIScreen mainScreen] applicationFrame];
MyDetailView *detailView = [[MyDetailView alloc] initWithFrame:frame];
self.view = detailView;
[detailView release];
}
现在我在视图中添加一些标签,f.e.
@property(nonatomic, retain) UILabel *descriptionLabel;
如果我想在我的 ViewController 中设置它,我通常会做类似的事情
self.view.descriptionLabel.text = @"foo";
因为这会产生一个警告,所以我可以把它改成
[[(MyDetailView*)self.view descriptionLabel] setText:@"foo"];
有没有更好的方法呢? F.E. 告诉我的 ViewController 视图属性是子类?有没有办法解决这个问题,或者我应该将我的详细视图保存在一个额外的 ivar 中?
感谢您的提示!
【问题讨论】:
标签: iphone objective-c ios uiview uiviewcontroller