gpt4 book ai didi

ios - presentViewController 显示白屏 10-15 秒

转载 作者:行者123 更新时间:2023-11-28 21:52:50 28 4
gpt4 key购买 nike

ChangePasswordPage *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"changedPass5"];
[self presentViewController:vc animated:YES completion:nil];

如果我将这段代码放在 viewDidLoad 中,它会起作用,但是当我在一个函数中运行它时,它仍然起作用,但是在 10-15 秒后出现白屏,然后屏幕正确加载.

这是为什么?

相关代码如下:

dispatch_queue_t queue = dispatch_queue_create("x.x", NULL);
dispatch_async(queue, ^{

while(true)
{
sleep(1);
checkCacheForRefreshDone = [[NSUserDefaults standardUserDefaults] stringForKey:@"homeScreenRefreshDone"];
userChangedPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userChangedPassword"];


if ([checkCacheForRefreshDone isEqualToString:@"1"])
{
[self installAfterRefresh];
[feedHomeTable reloadData];
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"homeScreenRefreshDone"];
[[NSUserDefaults standardUserDefaults] synchronize];
checkCacheForRefreshDone = @"0";
[refresh endRefreshing];
break;
}

}

});


-(void)installAfterRefresh
{

userChangedPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userChangedPassword"];

if ([userChangedPassword isEqualToString:@"1"])
{
[self detectPhone];
}
}

detectPhone使用presentViewController的函数

修复:添加此方法:

[self performSelectorOnMainThread:@selector(detectPhone) withObject:nil waitUntilDone:YES];

最佳答案

尝试在没有 self.storyboard 的情况下编写代码。

改变:

ChangePasswordPage *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"changedPass5"];
[self presentViewController:vc animated:YES completion:nil];

成为:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ChangePasswordPage *vc = [storyboard instantiateViewControllerWithIdentifier:@"changedPass5"];
[self presentViewController:vc animated:YES completion:nil];

关于ios - presentViewController 显示白屏 10-15 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27668132/

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