how to disable horizontal scroll for a uiwebview?

2019-09-19 06:13发布

问题:

I created a sample in which i imported a word(.docx)on to the uiwebview and displayed.I got the output but i don't want to display the horizontal scroll bar and the vertical scroll also working not properly i can see the black space behind the webview when i scroll it vertically. Here is my code:

#import <UIKit/UIKit.h>

@interface userguideLinesNewViewController : UIViewController {
    IBOutlet UIWebView *webView;
}
@property (nonatomic,retain) UIWebView *webView;
-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webViews;
@end
#import "userguideLinesNewViewController.h"

@implementation userguideLinesNewViewController
@synthesize webView;
-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webViews
{

 NSString *path = [[NSBundle mainBundle] pathForResource:@"BTBP CLARITY SKIN ADVISORuser.docx" ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:path];
 NSURLRequest *request = [NSURLRequest requestWithURL:url];
 [webViews loadRequest:request];
}
- (void)viewDidLoad {
    [super viewDidLoad];
 [self loadDocument:@"BTBP CLARITY SKIN ADVISORuser.docx" inView:self.webView];
}

回答1:

You could check others topics about this : Stop UIWebView from "bouncing" vertically? :-)

There isn't a method like in UIScrollView. But there is some kind of way to achieve your goal ;-)

Here is my way.

- (void)disableBounce {

    for (id subview in self.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;

}

Enjoy...