I can’t understand why this doesn’t work. I’m trying to display lblstatus when the timer cycle is hit:
-(void) viewDidAppear:(BOOL)animated
{
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(TimeForPictureCycle)
userInfo:nil
repeats:NO];
}
-(void)TimeForPictureCycle
{
while(YES)
{
[lblStatus setHidden:NO];
sleep(2);
[lblStatus setHidden:YES];
sleep(3);
}
}
Your calling
sleep()on the main thread, that means after you set your label tohiddenthat thread pauses and prevents the run loop from continuing thus it’s not able to update your UI. Your current code simple blocks your whole application.What you could do is this: