我有四个视图控制器(四个选项卡)的应用程序,和我想要的第四个负载UIWebView中的URL。请检查下面UIWebView的未加载
的代码本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
但是当我运行在iPhone模拟器,并到了第四个标签就不会加载网页,是什么问题?
在此先感谢
取消注释刷新,但仍然没有工作! – SimpleojbC 2013-02-24 15:09:01
如果你不使用IB(storyboard或xib),那么你应该创建你的webview。 'self.webview = [[UIWebView alloc] init]'在使用之前。 – Dave 2013-02-24 15:10:48
添加自我到webView加载请求,仍然不工作 – SimpleojbC 2013-02-24 15:11:11