gpt4 book ai didi

ios - SLComposeViewController 出现缓慢

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:36:23 29 4
gpt4 key购买 nike

SLComposeViewController 在呈现后需要 3-4 秒才能出现。但是 presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion 方法完成 block 会立即被调用。因此,即使我使用加载指示器,它也会在眨眼间消失。相关代码如下。顺便说一句,我试过 dispatch_async 它没有用。

我怎样才能加快这个过程,你有什么想法吗?

SLComposeViewController *shareView = [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
[shareView setTitle:@"Title"];
[shareView setInitialText:@"Description"];
[shareView addURL:[NSURL URLWithString:@"http://www.google.com/"]];
[shareView setCompletionHandler:^(SLComposeViewControllerResult result) {

switch (result) {
case SLComposeViewControllerResultCancelled:
{
NSLog(@"Facebook Post Canceled");
break;
}
case SLComposeViewControllerResultDone:
{
NSLog(@"Facebook Post Successful");
break;
}
default:
break;
}
}];

UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityView.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, [UIScreen mainScreen].bounds.size.height / 2.0);
[activityView startAnimating];
[self.view addSubview:activityView];

[self presentViewController:shareView animated:YES completion:^{
NSLog(@"Presented facebook");
[activityView removeFromSuperview];
}];

最佳答案

因此,这不是解决方法,但它可能会帮助您解决问题。我无法让事情显示得更快,我认为它只是在显示自身之前引入数据的实现。

由于 presentViewController 完成几乎立即执行,我的解决方法是显示一个进度 View ,并设置一个选择器在 2 秒后执行。选择器只是隐藏了进度 View ,这是一个示例。

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self performSelector:@selector(hideProgressView) withObject:nil afterDelay:2.0f];

[self presentViewController:self.composeViewController animated:YES completion:nil];


- (void)hideProgressView
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}

关于ios - SLComposeViewController 出现缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30124517/

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