您的位置:首页 > 理论基础 > 计算机网络

IOS系统中网络等待的Loading的实现方法的代码

2019-01-19 14:02 507 查看

在写内容过程中,把写内容过程中比较好的内容珍藏起来,下边内容内容是关于IOS系统中网络等待的Loading的实现方法的内容,希望能对码农有所帮助。

WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];
[WebView setUserInteractionEnabled:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setDelegate:self];

[WebView loadRequest:[NSURLRequest requestWithURL:url]];

[view setTag:103];
[view setBackgroundColor:[UIColor blackColor]];
[view setAlpha:0.8];
[self.view addSubview:view];

activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activityIndicator setCenter:view.center];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[view addSubview:activityIndicator];
[self.view addSubview:WebView];
[view release];
[WebView release];

[activityIndicator startAnimating];
}

[activityIndicator stopAnimating];
[view removeFromSuperview];
}

第二种方法:使用UIAlertViewandUIActivityIndicatorView

if (myAlert==nil){
myAlert = [[UIAlertView alloc] initWithTitle:nil
message: @"读取中..."
delegate: self
cancelButtonTitle: nil
otherButtonTitles: nil];

activityView.frame = CGRectMake(120.f, 48.0f, 38.0f, 38.0f);
[myAlert addSubview:activityView];
[activityView startAnimating];
[myAlert show];
}
}

[myAlert dismissWithClickedButtonIndex:0 animated:YES];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  网络等待