【发布时间】:2013-06-16 01:45:52
【问题描述】:
我正在使用 InAppSettingsKit 进行设置,并希望在表格视图页脚中添加公司超链接。我已经成功地在部分标题中添加了一个 uiwebview(它位于表格视图的底部并显示为页脚)。 webview 显示超链接,但不响应触摸。
在 settingsViewController:tableView:viewForHeaderForSection: 中创建 web 视图:
UIView *containerView = [[UIView alloc] init];
containerView.backgroundColor = [UIColor clearColor];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(30, 0, self.view.frame.size.width-60, 35)];
webView.delegate = self;
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:[NSDate date]];
NSUInteger fontSize = 13;
NSString *link = @"<a href=\"http://www.google.com\">My Hyperlink</a>";
[webView loadHTMLString:[NSString stringWithFormat:@"<html><head></head><body style=\"font-family: sans-serif;font-size:%dpx;\"> <center>Copyright © %d %@</center></body></html>", fontSize, dateComponents.year,link] baseURL:nil];
webView.backgroundColor = [UIColor clearColor];
webView.opaque = NO;
[containerView addSubview:webView];
return containerView;
和 uiwebview 委托方法:
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
DDLogVerbose(@"Web view should start load with request %@. InType: %d", inRequest.URL.absoluteString, inType);
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
谁能告诉我为什么触摸不起作用? 顺便说一句... webView:shoudStartLoadWithRequest: 在表格视图被加载/显示时立即被调用
谢谢!
【问题讨论】:
标签: ios uitableview uiwebview hyperlink footer