gpt4 book ai didi

ios - 如何在 ios 中加载进度条后将一个 View Controller 移动到另一个 View Controller

转载 作者:行者123 更新时间:2023-11-29 12:12:06 25 4
gpt4 key购买 nike

嗨,我是 iOS 的初学者,在我的项目中我正在使用进度条

这里我的主要要求是在完成进度条加载后最多 5 秒加载进度条我想为此移动另一个 View Controller 我使用了一些代码但没有工作请帮助我

- (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];
}
}

关于ios - 如何在 ios 中加载进度条后将一个 View Controller 移动到另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33147143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com