我是Objective-c的新手,并且已经被这个问题困扰了好几个星期了。所以非常感谢任何帮助。
我正在开发一个具有标签视图的i-phone应用程序,其中一个标签是UIWebView。另一个选项卡提供了一种选择UIWebView中应显示内容的方法。
我可以在UIWebView中显示初始视图(在viewDidLoad中):
[self.groupWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
效果非常好。
但是当用户在表视图上选择某些内容时,它必须在现有的UIWebView中打开一个新页面。
所以我有这个:
-(void) displayGroup:(int)theGroup
{
// Set our selves to the webviews delegate since we implement the delegate methods here
self.groupWebView.delegate = self;
// Load it to the webview
NSString *html = @"<html><head><title>it worked...</title></head><body><a href=\"custom://THIS_IS_CUSTOM_LINK\">Click for custom link</a><br><a href=\"http://google.com\">it worked...</a></body></html>";
[self.groupWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
}
我打电话给它并且它运行但在网络视图上没有任何反应。
<。> .h文件看起来像:// PBGroupViewController.h
#import <UIKit/UIKit.h>
@interface PBGroupViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate>
@property (nonatomic, retain) IBOutlet UIWebView *groupWebView;
- (void) displayGroup:(int)theGroup;
@end
非常感谢您对此的任何帮助......谢谢。
答案 0 :(得分:0)
像这样更改displayGroup
功能:
-(void) displayGroup:(int)theGroup
{
// Set our selves to the webviews delegate since we implement the delegate methods here
self.groupWebView.delegate = self;
// Load it to the webview
NSString *html = @"<html><head><title>it worked...</title></head><body><a href=\"custom://THIS_IS_CUSTOM_LINK\">Click for custom link</a><br><a href=\"http://google.com\">it worked...</a></body></html>";
[self.groupWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[self.groupWebView stopLoading ];
[self.groupWebView reload];
}
答案 1 :(得分:0)
当用户点击表格视图时会生成一些网址....如果是,那么你应该使用didSelectRowAtIndexPath,并且你应该加载你的网页浏览..