gpt4 book ai didi

iphone - iPhone 中的 UIActivityIndi​​catorView 出现问题?

转载 作者:行者123 更新时间:2023-11-29 04:21:42 26 4
gpt4 key购买 nike

目前我正在iPhone应用程序中工作,使用UIWebView(presentModelViewController中显示的网页)在屏幕上显示网页,然后我添加UIActivityIndi​​catorView以在加载url请求中显示,但UIActivityIndi​​catorView没有在屏幕上显示,我尝试过我的水平最好,请帮助我。

提前致谢

我尝试过这个:

- (void)viewDidLoad
{
[super viewDidLoad];

activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activity.frame=CGRectMake(140, 240, 40, 40);
[self.view addSubview:activity];

web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
web.delegate=self;
web.backgroundColor=[UIColor clearColor];
NSURL *url = [NSURL URLWithString:@"http://wrwr.rww.com/erqrrq"];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[web loadRequest:req];
[self.view addSubview:web];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[activity stopAnimating];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
[activity startAnimating];
}

最佳答案

将您的事件指示器 View 添加到您的 webView 中,如下所示:-

 - (void)viewDidLoad
{
[super viewDidLoad];

activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activity.frame=CGRectMake(140, 240, 40, 40);


web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
web.delegate=self;
web.backgroundColor=[UIColor clearColor];
NSURL *url = [NSURL URLWithString:@"http://wrwr.rww.com/erqrrq"];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[web loadRequest:req];
[web addSubview:activity];
[self.view addSubview:web];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[activity stopAnimating];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
[activity startAnimating];
}

关于iphone - iPhone 中的 UIActivityIndi​​catorView 出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12911503/

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