2014-03-04 103 views
0

我得到一個錯誤,我做了一個UIPageController的網絡,但我似乎無法找到它的問題,只有一個錯誤,請幫助。代碼如下 - 需要更多代碼。調試xcode階段?

@interface ContentViewController() 
@end 
@implementation ContentViewController 
- (void)viewWillAppear:(BOOL)animated { 
[super viewWillAppear:animated]; 
[_webView loadHTMLString: _dataObject baseURL:[NSURL URLWithString:@"http://"]]; 
} 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
} 
return self; 
} 
- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
} 
- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
} 
@end 

[_webView loadHTMLString: _dataObject baseURL:[NSURL URLWithString:@"http://"]]; 

我的 「錯誤是上述」

請幫

#import <UIKit/UIKit.h> 

@interface ContentViewController : UIViewController 
@property (strong, nonatomic) IBOutlet UIView *webView; 
@property (strong, nonatomic) id dataObject; 
@end 
+1

錯誤是什麼?你想從字符串或URL加載HTML嗎? – Rashad

+0

你能顯示錯誤信息嗎? – VietHung

+0

錯誤是「沒有可見@interface爲'UIView'聲明扇區'loadHTML_string:baseURL:' –

回答

1

更改.h文件到這一點:

#import <UIKit/UIKit.h> 

@interface ContentViewController : UIViewController 
@property (strong, nonatomic) IBOutlet UIWebView *webView; 
@property (strong, nonatomic) id dataObject; 
@end 

除此之外,如果要加載網頁在UIWebView從URL然後你可以這樣做:

self.webView.delegate = self; 
self.webView.scalesPageToFit =YES; // This will fit the page within the screen 
NSURL *Url = [NSURL URLWithString:@"http://facebook.com/xxx/xxx"]; 
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:Url]; 
[self.webView loadRequest:req]; 

如果要加載的文件從一個HTML文件,然後執行:

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"Test" ofType:@"html"]; 
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil]; 
[webView loadHTMLString:htmlString baseURL:nil]; 

或者,如果你只是想加載一個字符串,然後執行:

NSString* htmlString = @""; 
[webView loadHTMLString:htmlString baseURL:nil]; 

希望這有助於..: )

+0

謝謝 - 但我現在有一個更大的問題:我需要這個東西,我做了切換2頁面之間的頁面控制按鈕在底部,沒有捲曲!https://www.youtube.com/watch?v=6eFvIXDujb0 –

+0

看看這個:http:// www .appcoda.com/uipageviewcontroller-教程前奏/ – Rashad