开发者

iphone sdk: clickable image in UIWebView

开发者_JAVA百科I wanna wrap some text around a UIButton or clickable image in some kind of scrollview. My ide was to add an UIButton to an UIWebView, but thats not possible? Is there a way to wrap text around an UIButton in an UIScrollView or UITextView?

Or can I add an image to the UIWebView and handle the clicking somehow?


In the current SDK there is no easy way to wrap text around an image. You could make multiple UILabels and manually cut the strings up into pieces, but that is difficult in itself.

If you make the image a normal anchor, you can handle the opening of the link in the UIWebView delegate callbacks. Return NO and do whatever you want the image to do. You can use a custom scheme to make it easy to distinguish.

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( [[[inRequest URL] scheme] isEqualToString:@"myscheme"] ) {
    // do something
    return NO;
}
return YES; // normal link

}

In a UIWebView, you have nearly full access to css and javascript and can do almost anything you could do in Safari. You are not limited to using an anchor tag, that is just the easiest way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜