2009-11-19 70 views
0

我正在使用“loadHTMLString”创建一个webview和加载内容内容正在加载我只是无法让链接工作,因为链接到google.com。任何帮助都会很棒。带链接的UIWebView

UIWebView* newWeb = [[UIWebView alloc initWithFrame:CGRectMake(notificationPopUp.frame.origin.x+ 20,notificationPopUp.frame.origin.y-100,100, 100)]; 
//newWeb.backgroundColor = [UIColor clearColor]; 
newWeb.alpha = 0.7; 
newWeb.opaque= NO; 
newWeb.delegate= self; 
NSString *html = [NSString stringWithFormat:@"<html><head><title></title><style type=\"text/css\">a{text-decoration:none}</style></head><body><FONT COLOR=\"#484848\"><p>Hello this is a <a href=\"http://www.google.com\">Test</a></p></FONT></body></html>"]; 
[newWeb loadHTMLString:html baseURL:[NSURL URLWithString:@""]]; 
newWeb.userInteractionEnabled= TRUE; 
[notificationPopUp addSubview:newWeb]; 
+0

链接是否指向存储在应用程序捆绑中的资源? – 2009-11-19 21:46:31

+0

关于a)您期望链接所做的事情和b)您对目前所做事情的观察将有所帮助。 – fbrereto 2009-11-19 21:51:39

+0

在这个例子中我只是想去谷歌。主要是我只想链接到网站。 – wolffang 2009-11-19 22:04:19

回答

0

我将此代码添加到一个空的项目中,链接是可点击的。我唯一能想到的是你的notificationPopUp视图是以某种方式防止点击进入web视图。

+0

感谢您缩小它,找不到弹出框的工作,然后 – wolffang 2009-11-20 14:25:24

+0

是的,我将webview添加到按钮,可能没有收到任何接触。将其更改为将其添加到mainview的位置。 – wolffang 2009-11-22 22:31:24