Search code examples
iosobjective-cpdfuiwebviewuiscrollview

displaying pdf file in UIScrollview Horizontally


In a pdf file using UIWebView, I need to scroll horizontally instead of vertically. I have created UIScrollView in the form:

UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.contentSize = CGSizeMake(2000, 420);
scrollView.bounces = NO;
scrollView.alwaysBounceHorizontal = NO;
scrollView.alwaysBounceVertical = NO;
scrollView.backgroundColor = [UIColor whiteColor];

and now adding the UIWebView in to UIScrollView as

[scrollView addSubview:webView];

it is not displaying the pdf file but if i give code like this

[self.view addSubview:webView];

now it displays the file but it vertical scroll

I need to make it to scroll horizontally please help me. Thanks in advance.


Solution

  • After your code:

    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.contentSize = CGSizeMake(2000, 420);
    scrollView.bounces = NO;
    scrollView.alwaysBounceHorizontal = NO;
    scrollView.alwaysBounceVertical = NO;
    scrollView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:webView];
    

    add this also:

    [self.view addSubview:scrollView];
    

    if you have not added it earlier.