Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTimer Triggering UIProgressView Failure
    primarykey
    data
    text
    <p>I'm using a NSTimer in a NSObject class (Timer), that fires a method, that increments a variable and fires a method in a View Controller (InfoViewController). (Confused ;-D )</p> <p>Everything shows up on the screen and and the timer is started correctly. The variable f.hunger updates and shows the correct value (when using printf("%f", f.hunger) ) but the UIProgress bar doesn't update itself. f.hunger's starting value is 1.</p> <p>If anyone can help me, point out where I've made an obvious mistake or got a suggestion it would be most appreciated as it's been doing my head in for a good few hours now. I've added some sample code below to show what I'm doing a bit more clearly.</p> <p>Cheers everyone. :-D</p> <p>Timers Class</p> <pre><code>- (void)startHungerTimer { if(hungerTimer.isValid == NO) { infoVC = [[InfoViewController alloc] init]; self.hungerTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(incrementHungerTimer:) userInfo:nil repeats:YES]; } } - (void)incrementHungerTimer:(NSTimer *)aTimer { f.hunger -= 0.01; [infoVC updateHungerProgress]; } </code></pre> <p>Info View Controller</p> <pre><code>- (void)updateHungerProgress { Functions *f = [Functions sharedFunctions]; hungerBar.progress = f.hunger; } - (void)loadView { hungerBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; [hungerBar setFrame:CGRectMake(17.0, 30.0, 160.0, 10.0)]; hungerBar.progress = f.hunger; [bView addSubview:hungerBar]; [hungerBar release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload