问题描述
- UIWebView加载未成功
-
应用中有四个视图控制器(四个选项卡),需要用UIWebView加载一个URL。代码如下:
FourthViewController.h#import <UIKit/UIKit.h> @interface FourthViewController : UIViewController { IBOutlet UIWebView *webView; } @property(nonatomic,retain)IBOutlet UIWebView *webView; @end
FourthViewController.m
#import "FourthViewController.h" @interface FourthViewController () @end @implementation FourthViewController @synthesize webView; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { //self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.navigationItem.title = @"Instagram"; self.view.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; UIBarButtonItem *refreshButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshClicked:)] init]; self.navigationItem.rightBarButtonItem = refreshButton; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; } -(IBAction)refreshClicked:(id)sender { NSLog(@"Clicked"); } - (NSString *)tabImageName { return @"instagram"; } @end
但是在模拟器中运行后,加载未成功。请高手指点一下,谢谢。
解决方案
http://blog.csdn.net/lovenjoe/article/details/7498238
你看一下这两种加载方法
时间: 2024-09-14 20:42:59