2012-01-30 56 views
3

我已閱讀這裏的帖子,但無法完全適應他們的需求。我有:在XCode中檢測UIWebView表單提交

-(IBAction) abouthtml 
{ 
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]; 
NSURL *url = [NSURL fileURLWithPath:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
CGRect webViewRect = frameWebSpace; 
UIWebView *myWebPage=[[UIWebView alloc] initWithFrame:webViewRect]; 
[myWebPage loadRequest:requestObj]; 
[self.view addSubview:myWebPage]; 
} 

這顯示細膩,但我的「返回程序」,在about.html提交按鈕無法正常工作。

我試過,在這裏發貼建議:

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request 
navigationType:(UIWebViewNavigationType)navigationType 
{ 
if (navigationType == UIWebViewNavigationTypeFormSubmitted) 
{ 
    .... 

但很明顯,沒有任何鏈接myWebPage到web視圖。有人可以建議我錯過了什麼嗎? 我是否需要讓webView成爲myWebPage的代表?心慌意亂,但是希望...

回答

0

設置myWebPage的委託對象實現(在你的情況可能

-webView:shouldStartLoadWithRequest:navigationType: 
1

你必須設置的UIWebView委託是對象執行shouldStartLoadWithRequest,[myWebPage setDelegate:self],假設添加子視圖的類是您想要接收的shouldStartLoadWithRequest消息