我想在 webview od ios 11 中禁用放大缩小。我使用我在 AppDelegate.m 中使用的 xcode 9
1:-
- (void)webViewDidFinishLoad:(UIWebView *)webView {
webView.scalesPageToFit = NO;
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView
{
return nil;
}
2:-
- (void)webViewDidFinishLoad:(UIWebView *)webView {
webView.scrollView.maximumZoomScale = 1.0;
webView.scrollView.minimumZoomScale = 1.0;
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView
{
return nil;
}
3:-
- (void)hijackWebViewScrollViewDelegate:(UIWebView *)webView {
UIScrollView *scrollView = (UIScrollView *)[webView.subviews objectAtIndex:0];
scrollView.delegate = self;//xcode shows error in this is Assigning to 'id<UIScrollViewDelegate> _Nullable' from incompatible type 'AppDelegate *const __strong'**
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return nil;
}
4:-我在我的 AppDelegate.m 中使用这个并在 h 中应用 scrollViewDelegate 没有错误但没有达到要求。
@implementation AppDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
webView.scrollView.delegate = self;
webView.scrollView.maximumZoomScale = 1.0;
webView.scrollView.minimumZoomScale = 1.0;
webView.scalesPageToFit = NO;
webView.multipleTouchEnabled=NO;
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *) scrollView
{
return nil;
}