How To Update ProgressBar in iPhone

H

//———————
.h File
{
NSTimer *timer;
UIProgressView *myProgressBar;
int StartingValue;
}
@property (nonatomic, retain) UIProgressView *myProgressBar;

//————
.m File
@synthesize myProgressBar;

– (void)viewDidLoad
{
StartingValue = 0;

myProgressBar = [[UIProgressView alloc] init];
myProgressBar.frame = CGRectMake(25, 100, 235, 10);
myProgressBar.progress = 0.0f;
[self.view addSubview:myProgressBar];

timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateProgressBar) userInfo:nil repeats:YES];
}
– (void) updateProgressBar
{
StartingValue ++;

float result =((float) StartingValue/(float)100)*100.0;
myProgressBar.progress = result/100.0f;
}

About the author

abdulgafar.nurbash
By abdulgafar.nurbash

Category