我有四個視圖控制器(四個選項卡)的應用程序,和我想要的第四個負載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