当触摸在 webview 之外结束时,“onTouchEnd”不会触发。 使用 XCode 6、iOs 8、iPhone 6 编译
我有下一个布局:
|Navigation TAB|
|Left view|Web view|Right view|
|page view|
我可以在 WebView 中接收所有触摸事件,触摸开始和结束时。 但是,如果我在 webview 中开始触摸,然后将触摸移到它之外,我将在离开 webview 边界后立即停止接收 touchmove 事件,并且不会收到任何 touchend 事件。
测试 html 文件的代码:
<head>
</head>
<body bgcolor="#CC6"
ontouchmove="console.info('move');"
ontouchstart="console.info('start');"
ontouchend="console.info('end');"
ontouchcancelled="console.info('canceled');"
>
<h1>This is a test</h1>
<p> Lore ip sum </p>
</body>
“viewDidLoad”函数代码
[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];
如何解决这个问题?我是否遗漏了某些配置?
完整的源代码可以在这里找到:https://github.com/Daraku/WebViewBug
最佳答案
在过去的 30 分钟里,我一直在为同样的问题而苦苦挣扎,最后我决定实现一个超时,每次 touchmove 都会恢复超时,并从 touchstart 开始, 并在 touchend 时被清除。超时是指 1500ms,如果我没有从 webview 中触发 touchend,我会在超时结束时触发它。
希望我说明了一点。它并不完美,但可以作为部分修复。在我的案例中,iScroll( _execEvent('scrollCancel') )
关于IOS - 非全屏 webview 没有 "touchend"事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26721447/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub