gpt4 book ai didi

iOS - 默认事件加载器,如 "please wait"

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

我想在调用 API 或任何后台方法时在 uiview 中添加一个加载程序。它有任何默认值吗?或者我创建了自定义加载程序。

最佳答案

试试这个:

-(void)loaderType1 :(UIView *)View
{
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

activityView.center=View.center;
activityView.color=(UIColor*)[UIColor blackColor]; //change color
activityView.tag=10;
[activityView startAnimating];
//this is for freeze UI when loader appears
//[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
//this is for stop the previous action
//[[UIApplication sharedApplication] endIgnoringInteractionEvents];
[View addSubview:activityView];
[View bringSubviewToFront:activityView];
}

现在在任何地方都这样调用它 -

[self loaderType1: self.view];

删除加载程序:

 if ([self.view viewWithTag:10])
{
[[self.view viewWithTag:10] removeFromSuperview];
}

关于iOS - 默认事件加载器,如 "please wait",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48496983/

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