Ios6 IOS 6上未加载UIWebview
Ios6 IOS 6上未加载UIWebview,ios6,Ios6,shouldStartLoadWithRequest:navigationType和webViewDidStartLoad的UIWebview方法被调用一次,但之后活动指示器继续旋转(从webViewDidStartLoad开始)并且没有调用任何委托方法webviewdiffinishload或didFailLoadWithError。这只是IOS 6上的一个问题。这在IOS 5和IOS 6中对我有效。确保在Interface Builder中连接插座。你可能应该做一些检查,看看是否可以上网。我
shouldStartLoadWithRequest:navigationType
和webViewDidStartLoad
的UIWebview
方法被调用一次,但之后活动指示器继续旋转(从webViewDidStartLoad
开始)并且没有调用任何委托方法webviewdiffinishload
或didFailLoadWithError
。这只是IOS 6上的一个问题。这在IOS 5和IOS 6中对我有效。确保在Interface Builder中连接插座。你可能应该做一些检查,看看是否可以上网。我正在使用Apple可达性类进行此操作:
标题:
#import <UIKit/UIKit.h>
@interface HelpWebViewController : UIViewController <UIWebViewDelegate>
{
IBOutlet UIWebView *webView;
IBOutlet UIActivityIndicatorView *activityIndicator;
}
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
@property (nonatomic, strong) NSString *webHelpURLString;
- (void)webViewDidStartLoad:(UIWebView *)webView; //a web view starts loading
- (void)webViewDidFinishLoad:(UIWebView *)webView;//web view finishes loading
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error; //web view failed to load
@end
如果显示代码,您可能会得到更多帮助。如果没有这些,唯一的猜测是您没有设置UIWebViewDelegate。
#import "HelpWebViewController.h"
#import "Reachability.h" // Needs System Configuration Framework
@interface HelpWebViewController ()
@end
@implementation HelpWebViewController
@synthesize webView = ivWebView;
@synthesize activityIndicator = ivActivityIndicator;
@synthesize webHelpURLString = ivWebHelpURLString;
-(BOOL)reachable {
Reachability *r = [Reachability reachabilityWithHostName:@"apple.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if(internetStatus == NotReachable) {
return NO;
}
return YES;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSURL *webHelpURL = [NSURL URLWithString:@"support.apple.com"];
NSURLRequest *myrequest = [NSURLRequest requestWithURL:webHelpURL];
[self.webView loadRequest:myrequest];
self.webView.scalesPageToFit = YES;
if ([self reachable]) {
NSLog(@"Reachable");
}
else {
NSLog(@"Not Reachable");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"cantOpenWebPageAlertTitle", @"Cannot Open Page - UIAlert can't open web page")
message:NSLocalizedString(@"cantOpenWebPageAlertMessage", @"The page cannot be opened because you're not connected to the Internet.")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"cantOpenWebPageAlertOKButton", @"OK - accept alert")
otherButtonTitles:nil];
[alert show];
alert = nil;
}
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[self.activityIndicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self.activityIndicator stopAnimating];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[self.activityIndicator stopAnimating];
}
@end