目前我正在使用 iphone 应用程序,使用 UIWebView(presentModelViewController 中显示的网页)在屏幕上显示网页,然后我添加 UIActivityIndicatorView 以显示在加载 url 请求中,但 UIActivityIndicatorView 没有显示在屏幕上,我尽力了, 请帮我。
提前致谢
我试过这个:
- (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];
}