Mel*_*ina 6 iphone objective-c uiwebview
我知道你可以使用javascript来做到这一点
<script type="text/javascript">
touchMove = function(event) {
event.preventDefault();
}
Run Code Online (Sandbox Code Playgroud)
有没有办法使用objective-c做同样的事情?
试试这个...
UIView * v = [[webView subviews] lastObject];
[v setScrollEnabled:NO];
[v bounces:NO];
Run Code Online (Sandbox Code Playgroud)
编辑:根据下面的评论添加原始答案的检查
UIView * v = [[webView subviews] lastObject];
if([v isKindOfClass:[UIScrollView class] ]) {
if ([v respondsToSelector:@selector(setScrollEnabled]) {
[v setScrollEnabled:NO];
}
if ([v respondsToSelector:@selector(bounces)]) {
[v bounces:NO];
}
}
Run Code Online (Sandbox Code Playgroud)