【发布时间】:2016-11-18 10:11:08
【问题描述】:
我已经创建了我在 UIViewController 上代表的自定义 UIView。视图显示在屏幕上,但我在该 UIView 实例上设置为 YES 的 BOOL 无法识别。
代码:
UIView 实现:
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self createInterface];
}
return self;
}
-(void)createInterface
{
if (self.isSplash == YES) {
self.backgroundColor = [UIColor clearColor];
}
else {
self.backgroundColor = DARK_BLUE;
[self setupTimer];
}
....
视图控制器:
self.sponsorView = [[SponsorMechanismView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.logo.frame)+10, SCREEN_WIDTH, 100)];
self.sponsorView.isSplash = YES;
[self.view addSubview:self.sponsorView];
所以,我将 BOOL 设置为 YES,但在这个 UIView 中它始终为 NO。
【问题讨论】:
-
将
isSplash设置为true时,createInterface方法已经执行完毕。 -
知道如何解决这个问题吗?
-
当然,如果
isSplash发生变化,覆盖isSplash的设置器并在那里调用createInterface。 -
@FabioBerger 请将此添加为答案,以便我接受!
标签: ios objective-c iphone uiview uiviewcontroller