about window.pageYOffset,document.body.scrollTop not working in iOS 7
2013-10-24 01:07
549 查看
最近在升级应用支持iOS7时,发现了一个长期以来都存在的bug。
针对UIWebView 内部实现的UIScrollViewDelegate委托,我们在开发过程中,经常会直接继承UIWebView,并且OverWrite 他的UIScrollViewDelegate。
这样的写法在使用iOS6 SDK 以及iOS6 以下编译都没有出现过问题。但是最近在使用iOS7 SDK编译后,发现在UIWebView脚本调用的时候,window.pageYOffset,document.body.scrollTop 等属性失效,刚开始一直认为是iOS7 是不是针对UIWebView 的 Safari做了什么特殊处理,后来还google了好长一段时间,还发现了一些跟我出现相同问题的coder。
http://stackoverflow.com/questions/19001892/window-pageyoffset-not-working-in-ios7
某些时候,我还一直以为是iOS7的bug。后来分析了线上的几款应用,发现别人是正常的。XX。。那肯定是应用本身的问题。
后来当把注意力转移到UIWebView本身时候,才发现,在开发过程中,经常的去继承,但是并没有注意到父类本身委托的实现。
该bug的解决,只需要。。
好吧。。
针对UIWebView 内部实现的UIScrollViewDelegate委托,我们在开发过程中,经常会直接继承UIWebView,并且OverWrite 他的UIScrollViewDelegate。
#pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //TODO }
这样的写法在使用iOS6 SDK 以及iOS6 以下编译都没有出现过问题。但是最近在使用iOS7 SDK编译后,发现在UIWebView脚本调用的时候,window.pageYOffset,document.body.scrollTop 等属性失效,刚开始一直认为是iOS7 是不是针对UIWebView 的 Safari做了什么特殊处理,后来还google了好长一段时间,还发现了一些跟我出现相同问题的coder。
http://stackoverflow.com/questions/19001892/window-pageyoffset-not-working-in-ios7
某些时候,我还一直以为是iOS7的bug。后来分析了线上的几款应用,发现别人是正常的。XX。。那肯定是应用本身的问题。
后来当把注意力转移到UIWebView本身时候,才发现,在开发过程中,经常的去继承,但是并没有注意到父类本身委托的实现。
该bug的解决,只需要。。
#pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [super scrollViewDidScroll:scrollView]; }
好吧。。
相关文章推荐
- js兼容写法为document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
- 关于window.pageYOffset和document.documentElement.scrollTop
- 关于window.pageYOffset和document.documentElement.scrollTop
- 分享js中 pageY = clientY + document.body.scrollTop 之间的关系
- JavaScript 滚动条示例,控制居中document.documentElement.scrollTop,document.body.scrollTop,oDiv.offsetHeight
- 关于document.body、document.documentElement、window.pageYoffset
- window.document.body.scrollTop 为零的为题
- 页面各元素位置和距离对象关系图解。 (深入document.documentElement、body.clentTop、div.scrollTop、div.scrollHeight、body.offsetWidth and so on)
- window.pageyoffset和document.body.scrollTop
- JS中--document.body.scrollTop 值总为0的解决方法
- document.body.scrollTop 值总为0的解决方法
- document.body.scrollTop与document.documentElement.scrollTop兼容
- 火狐、谷歌、IE关于document.body.scrollTop和document.documentElement.scrollTop 以及值为0的问题
- 获取scrollTop兼容各浏览器的方法,以及body和documentElement是啥?
- 火狐、谷歌、IE关于document.body.scrollTop和document.documentElement.scrollTop 以及值为0的问题 博客分类: IE火狐、谷歌javascript
- document.body.scrollTop 值总为0的解决方法 比较常见的标准问题
- document.body.scrollTop总是零的原因
- document.body.scrollTop用法
- document.body.scrollTop用法
- document.body.scrollTop用法