我的 viewWillAppear 方法调用“-(void)doSomething”。
- (void)doSomething
{
Y4AppDelegate * delegate = (Y4AppDelegate *)[[UIApplication sharedApplication] delegate];
if(delegate.booSomeValue == 0) {
UIButton * aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[aButton setFrame:CGRectMake(20,360,280,40)];
[aButton setTitle:@"Title"
forState:UIControlStateNormal];
[aButton addTarget:self
action:@selector(mySelector)
forControlEvents:UIControlEventTouchDown];
[self.view addSubview:aButton];
}
}
它可以工作,但 aButton 仍然可见。我该怎么做才能隐藏aButton?我有三个 UIViewController。第三,我将 delegate.booSomeValue 设置为 true。当我回到之前的 UIViewController 时,我调用了这个 viewWillAppear,但是 aButton 是可见的。我想隐藏它。