Note that there are some explanatory texts on larger screens.

plurals
  1. PONSScrollView sometimes has a black bar instead of scroller
    primarykey
    data
    text
    <p>In my document based OS X app, I have an empty NSScrollView in the xib, with "show vertical scroller" set. At run time I generate a view with buttons for navigation, which I set as the document view for the NSScrollView. Most of the time, this works well, but about 25% of the time, seemingly at random (or at least I can't reproduce any particular condition yet!), instead of a scroller on the side, I get a black bar where the scroller should be. If I resize the window, the black bar disappears, the scroller appears and works fine. </p> <p>The result is that if I open six or seven blank documents, one after the other, about 3 of them will not have immediately functioning scrollviews. </p> <p>Here is the code that creates the view with the navigation buttons, and adds it as the NSScrollview's documentView. </p> <p>YMScrollDocView is a subclass of NSView that sets isFlipped to YES. navScrollView is the outlet to the scrollview in xib. </p> <pre><code> float allHeight = 0.f; // Consider starting from the top //float xOffset = 2.f; // Offset addjustments float spacing = 4.f; // Spacing float buttonCellHeight = 40.f; YMScrollDocView *navView = [[YMScrollDocView alloc]init]; //1 NSButton *overviewButton = [[NSButton alloc]initWithFrame:NSMakeRect(0, allHeight, self.navScrollView.bounds.size.width, buttonCellHeight)]; [overviewButton setTitle:@"Overview"]; [overviewButton setButtonType:NSMomentaryLight]; [overviewButton setBordered:NO]; [[overviewButton cell]setBackgroundColor:[self colorWithHexColorString:@"30BDF8"]]; [overviewButton setBezelStyle:NSRegularSquareBezelStyle]; [overviewButton setButtonType:NSCellIsBordered]; [overviewButton setTarget:self]; [overviewButton setAction:@selector(goToOverview)]; [overviewButton setRefusesFirstResponder:YES]; [navView addSubview:overviewButton]; allHeight += buttonCellHeight; allHeight += spacing; //2 NSButton *curriculumButton = [[NSButton alloc]initWithFrame:NSMakeRect(0, allHeight, self.navScrollView.bounds.size.width, buttonCellHeight)]; [curriculumButton setTitle:@"Curriculum"]; [curriculumButton setButtonType:NSMomentaryLight]; [curriculumButton setBordered:NO]; [[curriculumButton cell]setBackgroundColor:[self colorWithHexColorString:@"36FBF8"]]; [curriculumButton setBezelStyle:NSRegularSquareBezelStyle]; [curriculumButton setButtonType:NSCellIsBordered]; [curriculumButton setTarget:self]; [curriculumButton setAction:@selector(goToCurriculum)]; [curriculumButton setRefusesFirstResponder:YES]; [navView addSubview:curriculumButton]; allHeight += buttonCellHeight; allHeight += spacing; </code></pre> <p>(I add more buttons with repetitive code here, then finish with the following code.)</p> <pre><code>[navView setFrame:NSMakeRect(1, 1, self.navScrollView.bounds.size.width, allHeight)]; [[self navScrollView]setDocumentView:navView]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload