Max.L Max.L - 5 months ago 27
Objective-C Question

IOS - No "touchend" event for not fullscreen webview

"onTouchEnd" is not firing when touch ends outside of webview.
Compile with XCode 6, iOs 8, iPhone 6

I have next layout:

|Navigation TAB|
|Left view|Web view|Right view|
|page view|

I can receive all touch events, when touch starts and ends, in web view.
But if I start touch in webview and then move touch outside of it, I would stop receiving touchmove events as soon as I leave webview border, and no touchend event is received.

Code fot test html file:

<body bgcolor="#CC6"
<h1>This is a test</h1>
<p> Lore ip sum </p>

Code of "viewDidLoad" function

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.webView = [[UIWebView alloc] initWithFrame:self.mainView.bounds];

[self.webView setScalesPageToFit:YES];
[self.webView setAlpha:1];

/* Disable scrolling of web view */
for (id subview in [self.webView subviews]) {
if ([subview isKindOfClass:[UIScrollView class]]) {
((UIScrollView*)subview).bounces = NO;

self.webView.scrollView.bounces = NO;
self.webView.scrollView.canCancelContentTouches = NO;
self.webView.scrollView.scrollEnabled = NO;

self.webView.backgroundColor = [UIColor magentaColor]; //[UIColor colorWithRed:(45.0/255.0) green:(50.0/255.0) blue:(53.0/255.0) alpha:1];
self.webView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin| UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.mainView addSubview:self.webView];

NSString * localHtmlFilePath = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"html" inDirectory:@"www"];
NSString *html = [NSString stringWithContentsOfFile:localHtmlFilePath encoding:NSUTF8StringEncoding error:nil];

[self.webView loadHTMLString:html baseURL:nil];

How this can be fixed? Is there are some configuration that I missed?

Complete source code can be found here:


I have been strugling with the same for past 30minutes, in the end i've decided to implement a timeout which is getting restored with every touchmove and starts on touchstart, and gets cleared on touchend. Timeout is for lets say 1500ms, and if i don't get touchend fired from within the webview as it should, i fire it when the timeout ends.

Hope i made a point. Its not perfect but serves as partial fix. In my case hackaround for iScroll( _execEvent('scrollCancel') )