问题描述
我在看WWDC 2014视频,适用于Mac的Scroll View编程指南。
I'm looking at WWDC 2014 video, "212: Storyboards and controllers on OS X". In this video they claim that Pages UI does/could be arranged using Storyboards on OS X (see below).
However, in Pages UI the inspector view is very long and is embedded in a scroll view (you can verify this my two-finger scrolling in Page.app inspector view), also some inspector items are themselves contained in (some type of custom) disclosure view. It doesn't seem to be possible to embed a storyboard view controller in scroll view because there is no corresponding to "scroll view controller" class. Is that right?
How can a storyboard view controller's view be embedded in a scroll view on a storyboard?
I have tried direct embedding at run time, however, this is very hackish and does't work reliably (problems with auto-layout). This route still might be possible, but I wanted to get advice before going too far. For real UI it might be the case of falling back to XIBs.
- (void)viewDidLoad {
[super viewDidLoad];
// Swap the view controllers' view for a scroll view
NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:self.view.frame];
scrollView.documentView = self.view;
scrollView.drawsBackground = NO;
self.view = scrollView;
}
- Create the view that will be the document view of the scroll view.
- Select that view
- Go to Editor > Embed In > Scroll View
Based on this page of Scroll View Programming Guide for Mac.
这篇关于如何在NSScrollView OS X(10.10)中嵌入一个故事板视图控制器,使复杂的检查器视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!