Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoa WebView scrollbars won't disappear

I load the webview and set allowsScrolling to NO, but webview still shows scroll bars... Banging your head on your computer hurts a lot more now that MacBooks have sharp metal edges.

My code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    NSString *webFolder = @"file:///<WebFolderPath>";
    [[[productWeb mainFrame] frameView] setAllowsScrolling:NO];
    [productWeb setFrameLoadDelegate:self];
    [[productWeb mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[webFolder stringByAppendingString:@"webpage.html"]]]];
}

I even setup the frame loading delegate to report about the scrolling status:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
    NSLog(@"Scrolling %@",[[frame frameView] allowsScrolling] ? @"Allowed" : @"Not Allowed");
    [[frame frameView] setAllowsScrolling:NO];
    NSLog(@"Scrolling %@",[[frame frameView] allowsScrolling] ? @"Allowed" : @"Not Allowed");
}

Which still gives me the unhappy:

2010-08-24 15:20:09.102 myApp[30437:a0f] Scrolling Allowed
2010-08-24 15:20:09.104 myApp[30437:a0f] Scrolling Not Allowed

And yet the scrollbars continue to show! Hopefully, it is something stupid I'm doing as I don't want to get any more blood on my laptop.

like image 536
BadPirate Avatar asked Aug 24 '10 22:08

BadPirate


1 Answers

I found I had to edit the HTML of the page I was trying to display to make sure that it was setup to take the full screen (and not more)... there was a DIV that had a minimum width set. Once I made sure the body had height = 100% and that none of the DIV's had a fixed or minimum width set that was smaller then the box I wanted to show it in everything came together :)

like image 146
BadPirate Avatar answered Oct 01 '22 23:10

BadPirate