내 문서 기반 OS X 응용 프로그램에서는 "show vertical scroller"가 설정된 xib에 빈 NSScrollView가 있습니다. 런타임에 NSScrollView에 대한 문서보기로 설정 한 탐색 용 단추가있는보기를 생성합니다. 대부분의 경우이 방법이 효과적이지만 시간의 약 25 %는 겉보기에 무작위로 (또는 적어도 특정 조건을 재현 할 수 없습니다!) 측면의 스크롤러 대신 검정색 막대가 나타납니다. 스크롤러가 있어야합니다. 창 크기를 조정하면 검정색 막대가 사라지고 스크롤러가 나타나 잘 작동합니다.NSScrollView는 때때로 스크롤러 대신 검은 색 막대를 가지고 있습니다.
결과적으로 6 개 또는 7 개의 빈 문서를 차례로 열면 약 3 개는 즉시 작동하는 scrollviews를 가지지 않습니다.
다음은 탐색 버튼을 사용하여보기를 만들고 NSScrollview의 documentView로 추가하는 코드입니다.
YMScrollDocView는 isFlipped를 YES로 설정하는 NSView의 하위 클래스입니다. navScrollView는 xib에서 scrollview의 콘센트입니다.
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;
은 (내가 다음 코드로 마무리, 여기에 반복적 인 코드로 더 많은 버튼을 추가 할 수 있습니다.) 나는 (약간 스크롤바를 참조하도록 수정) 코드를 실행
[navView setFrame:NSMakeRect(1, 1, self.navScrollView.bounds.size.width, allHeight)];
[[self navScrollView]setDocumentView:navView];
내 생각 엔 임베디드 뷰를 원하는 크기가되도록해야한다고 생각합니다. (스콜 뷰 크기로 크기를 조정하지 마십시오). 스크롤 뷰는 나머지 부분에 대해 걱정할 것입니다. – trojanfoe
삽입 된 뷰에 설정된 너비를 지정하여 전환했지만 여전히 동일한 동작을 얻고 있습니다. –