Hi I am beginner in iOS in my project I am using progress bar
And here my main requirement I want load progress bar up-to 5 seconds after completing that progress bar loading I want to move another view controller for this I have used some code but not working please help me
- (void)viewDidLoad
{
[super viewDidLoad];
self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
self.progressView.center = self.view.center;
[self.view addSubview:self.progressView];
self.myTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateUI:) userInfo:nil repeats:YES];
}
- (void)updateUI:(NSTimer *)timer
{
self.progressView.progress += 0.5;
ContactVC*VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactVC"];
[self.navigationController pushViewController:VC animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
progressView.center = self.view.center;
[self.view addSubview:progressView];
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateUI:) userInfo:nil repeats:YES];
}
- (void)updateUI:(NSTimer *)timer
{
progressView.progress += 0.5/10;
if ((int)progressView.progress) {
[myTimer invalidate];
Demoview*VC = [self.storyboard instantiateViewControllerWithIdentifier:@"Demoview"];
[self.navigationController pushViewController:VC animated:YES];
}
}
Update this method:
- (void)updateUI:(NSTimer *)timer
{
self.progressView.progress += 0.5/100;//because this limit is [0-1]. So, you have divide each progress unit by 100 in order to show percentage progress.
NSLog(@"%f",self.progressView.progress);
if ((int)self.progressView.progress) {
NSLog(@"Call View");
[self.myTimer invalidate];
self.myTimer = nil;//so that timer not fire again
ContactVC *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactVC"];
[self.navigationController pushViewController:VC animated:YES];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.