gpt4 book ai didi

ios - 单击 UITableview 行后 UIActivityIndi​​catorView 不显示?

转载 作者:行者123 更新时间:2023-11-29 01:43:21 24 4
gpt4 key购买 nike

点击后指示器不显示,它首先加载下一页,然后显示几毫秒。我希望它从行单击开始一直保留在那里,直到下一个屏幕完全加载。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame = CGRectMake(0,0,50,50);
activityIndicator.tintColor = [UIColor blackColor];
activityIndicator.center = self.view.center;
[self.view addSubview:activityIndicator];
[activityIndicator startAnimating];

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"6"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
}

最佳答案

尝试更改代码,以便将 UIActivityIndi​​catorView 代码放在主线程上。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
dispatch_async(dispatch_get_main_queue(), ^{
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame = CGRectMake(0,0,50,50);
activityIndicator.tintColor = [UIColor blackColor];
activityIndicator.center = self.view.center;
[self.view addSubview:activityIndicator];
[activityIndicator startAnimating];
});


UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"6"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
}

关于ios - 单击 UITableview 行后 UIActivityIndi​​catorView 不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32177221/

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