views:

294

answers:

1

Hi.

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?

A: 

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.

drawnonward
Thank you, that worked:)
origon