6
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGRect viewRect = CGRectMake(250, 100, 30, 30);
as = [[UIImageView alloc] initWithFrame:viewRect];
as.backgroundColor=[UIColor clearColor];
UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"check" ofType:@"png"]];
[as setImage:img];
[self.view addSubview:as];
BOOL test= [[NSUserDefaults standardUserDefaults] boolForKey:@"switch"];
NSLog(@"%@", (test ? @"YES" : @"NO"));
if(test == YES)
{
as.hidden=NO;
}
else
{
as.hidden=YES;
}
}
的test
結果YES
但imageView
不聽指揮.hidden
或更新每次當viewDidAppear
。如果它不是,當我重新啓動應用程序,它消失,我把它變成是我展現完美,但經過後比我永遠不會總是在那裏我不能讓它隱藏。 任何想法,爲什麼它沒有反應?如何隱藏/顯示UIimageview?