如何在 ios 中加载进度条后将一个 viewcontroller 移动到另一个 viewcontroller
How to move one viewcontroller to another viewcontroller after loading progressbar in ios
嗨,我是 iOS 的初学者,在我的项目中,我正在使用进度条
我的主要要求是在完成进度条加载后最多 5 秒加载进度条我想为此移动另一个视图控制器我使用了一些代码但没有工作请帮助我
- (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)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];
}
}
- (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];
}
}
嗨,我是 iOS 的初学者,在我的项目中,我正在使用进度条
我的主要要求是在完成进度条加载后最多 5 秒加载进度条我想为此移动另一个视图控制器我使用了一些代码但没有工作请帮助我
- (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)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];
}
}
- (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];
}
}