我在这里阅读了这些帖子,但不能很好地适应我的需求。我有:
-(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链接到webView。有人可以建议我缺少什么吗? 我是否需要将webView作为myWebPage的委托?困惑,但充满希望...
答案 0 :(得分:1)
你必须将UIWebView
的委托设置为实现shouldStartLoadWithRequest
,[myWebPage setDelegate:self]
的对象,假设添加子视图的类是你想要接收的shouldStartLoadWithRequest
1}}消息
答案 1 :(得分:0)
将myWebPage
委托设置为实现的对象(在您的情况下可能是 self )
-webView:shouldStartLoadWithRequest:navigationType: