UIWebView touch event

Member
Posts: 94
Joined: 2008.08
Post: #1
Hi,

Im holding some formatted text in a UIWebview, and I need to handle basic swipes so that I can change the contained text. The problem is that the web view captures all the user touches before I can see what they are. I have a view controller which Im adding a UIWebView object to, and Im then adding a custom UIView as a subView of this.

some sample code to help explain:
Code:
// in the main view controller
webView = [[UIWebView alloc] initWithFrame:webFrame];  
//this is the custom UIView
swipes = [[[Swipes alloc] initWithFrame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)] autorelease];
[webView addSubview:swipes];

self.view = webView;

//in the touchesBegan etc functions within Swipes and the main viewController
if(self.superview)
    [self.superview touchesBegan:touches withEvent:event];

Where should I be putting the touchesMoved etc functions? I've tried adding them to the custom UIView and to the view controller directly but it still doesnt work Sad
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #2
Hi,

To me it looks like you should disable touch handling on the WebView and do your touch handling on the UIView which embeds the WebView. You can delegate some events to the WebView. This technique is used in the iphone-google-maps-component. See its sources for example.

Here is your link: http://code.google.com/p/iphone-google-maps-component/

HTH,
Alex
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Timer and Touch Event concurrent issue claudie 7 4,121 Aug 9, 2009 06:05 PM
Last Post: claudie
  UIWebView in UIScrollView anto66r 0 3,808 Apr 22, 2009 04:54 AM
Last Post: anto66r