- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在观看 WWDC 2014 视频“212: Storyboards and controllers on OS X”。在这段视频中,他们声称 Pages UI 确实/可以使用 OS X 上的 Storyboards 进行排列(见下文)。
但是,在 Pages UI 中,检查器 View 非常长,并且嵌入在 ScrollView 中(您可以在 Page.app 检查器 View 中验证我的两根手指滚动),而且一些检查器项目本身也包含在(某些类型自定义)披露 View 。似乎不可能在 ScrollView 中嵌入 Storyboard View Controller ,因为没有对应的“ ScrollView Controller ”类。是这样吗?
如何将 Storyboard View Controller 的 View 嵌入到 Storyboard的 ScrollView 中?
我尝试过在运行时直接嵌入,但是,这是非常黑客的并且不能可靠地工作(自动布局问题)。这条路线仍然可能可行,但我想在走得太远之前寻求建议。对于真实的 UI,可能会回退到 XIB。
- (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;
}
最佳答案
我认为这个答案并不能真正解决您的问题,但可能有助于理解 Storyboard和 ScrollView 的情况。我认为苹果仍然需要解决一些 Storyboard问题。我尝试将 Collection View 与 Storyboard 一起使用,但无法在界面生成器中连接 collectionViewItem(这会在 xibs 中自动发生)。
这是一个 Collection View 的示例:
进行一些编码以连接 Collection View 项
class IVMyCollectionViewController: NSViewController, NSCollectionViewDelegate {
// manual connections to collection view (which is not working in IB)
@IBOutlet weak var collectionView: NSCollectionView!
class var sharedInstance : IVMyCollectionViewController {
struct Static {
static var instance:IVMyCollectionViewController? = nil
}
if Static.instance != nil {
return Static.instance!
} else {
let bundle = NSBundle.mainBundle()
let infoDict = bundle.infoDictionary!
let sbName = infoDict["NSMainStoryboardFile"] as String
let storyboard = NSStoryboard(name:sbName, bundle:bundle)!
let vcName = "MyCollectionView"
let sbInstance = storyboard.instantiateControllerWithIdentifier(vcName) as IVMyCollectionViewController
Static.instance = sbInstance
return sbInstance
}
}
// implement your controller
}
这意味着某些 UI 元素尚未正确实现。我会向苹果发送错误报告。界面构建器中仍然缺少很多东西。
现在,我将混合使用 Storyboard 和 xib,通过在 Controller 的构造函数中实例化连接,以上述方式滥用 Storyboard 。您可以使用storyboardID 启动 View 和其他 View 或从xib 加载。您可以将 viewController 放置在没有连接(segues)的 Storyboard中,以创建可以像 xibs 一样使用的 View 池。 (viewController 或多或少与 xib 相同)
// objC
DetailViewController* controller = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
或者像上面一样使用storyboardID进行实例化。
尝试在 Storyboard中创建 ScrollView 。为每个 View 创建您希望在 viewControllers 中显示的 View 。您的 ScrollView View Controller 应该与 ScrollView 本身有连接。在以下示例中, ScrollView 的导出名为“self.contentView”:
// instantiate a view controller for your scrolling view
self.scrollingViewController = [[ScrollingViewController alloc] initWithNibName:@"ScrollingView" bundle:nil];
// or do the same with storyboards by instantiating view controllers by ID
self.scrollingViewController = [myStoryboard instantiateControllerWithIdentifier:@"MyScrollingViewID"];
// Then set the view from the controller as content view
[self.contentView setDocumentView:self.scrollingViewController.view];
[self.contentView.contentView scrollPoint:NSMakePoint(0., self.scrollingViewController.view.frame.size.height)];
这就像混合 Objective C 和 swift 代码一样。苹果似乎已经进入了一条没有走到尽头的转型之路。
一般来说,您应该认为 Storyboard中的 View- 或 WindowControllers 与完整的 xib 文件相同。如果您想使用更多 View ,请在 Storyboard中使用容器 View 。 xibs 中的 FilesOwner 是 Storyboard 中的 viewController。容器 View 使您能够创建附加到 View Controller 的几个 View 。 Segue 机制可用于容器。我认为OS X的 ScrollView 机制并不优雅。我也为此挣扎了很多。
祝你好运!
关于macos - 如何在 NSScrollView OS X (10.10) 中嵌入 Storyboard View Controller 以创建复杂的检查器 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27440433/
我在 iOS 项目中创建了一个新目标并添加了一些我的文件以及一个新的 Storyboard文件。但是当在模拟器中运行时(我还没有尝试过该设备)它会吐在 UIApplicationMain(argc,
The document "Storyboard.storyboard" could not be opened. Could not read archive. Please use a newer
我的 .travis.yml 文件: language: objective-c script: xctool -project ProjectName. xcodeproj -scheme
我正在使用 Storyboard,因为我有一个定制的表格。我需要在单元格内的标签上显示值。我尝试为它创建一个 IBOutlet,但它似乎不接受它,它给了我一个错误消息,“连接“xyz”不能将原型(pr
Xcode 6 界面生成器默认有新的复选框“使用大小类别”。它使 View 具有适应性。 当我尝试在 Storyboard中的两个 View 之间进行连接时,我有新的选择: 代替旧的: 现在我们有“s
我在新的 xcode beta 版本中打开我的项目时犯了一个错误 现在我无法用稳定版本打开它,因为 The document “Main.storyboard” requires at least X
如果我有一个已经使用 Storyboard 的 Xcode 项目,现在我想切换到以编程方式加载 View Controller ,我该怎么做? 最佳答案 这是一个in-depth article关于这
[错误]:**构建失败** [错误]:以下构建命令失败: [错误]:编译Storyboard LaunchScreen.storyboard [错误]:(1 次失败) 如何解决这个问题?它不会在 io
我试图找到一种方法来处理多个目标(从一个项目部署多个应用程序),我不知道如何定义UIColor并在 Storyboard 中使用它(我可以为UIImage做得很好)。我的想法是使用宏根据目标切换此颜色
我有一个在 Xcode 5.1 中构建的带有 2 个 Storyboard的项目。 当我在 Xcode 6 中打开其中任何一个时,我收到此错误。他们从未在任何测试版中打开过,所以我认为这不是 Xcod
我想将 StoryBoard 添加到以编程方式制作的项目中,是否可以这样做。 最佳答案 是的,您可以向 Xcode 项目添加新的 Storyboard。我正在分享以下屏幕截图,请检查: 您可以为该 S
我将几个配置文件分成多个 Storyboard以尝试帮助我减少卡住时间,因为我听说许多 Storyboard可能是 Xcode 有时会“卡住”长达 10 分钟的原因,有时会导致我的流程崩溃工作的。所以
我是 iOS 开发新手,我知道这是一个非常简单的问题,但我真的无法理解原因。 当我构建 SingleViewApplication 时,Xcode 自动生成 LaunchScreen.storyboa
为什么 Storyboard.SetTargetName 有效而 Storyboard.SetTarget 无效?这里 xaml -
我使用的是 Xcode 7.1,我正在使用 Storyboard 引用转到不同的 Storyboard 。问题是每次我运行模拟器时,都会出现一个错误,提示 “没有找到从 Main.storyboard
因此,我开始在XCode 4.3.2中使用 Storyboard 。我从Master-Detail应用程序(iPad的拆分 View 应用程序)开始。在详细信息 View (名为DetailVC)中,
我想在我的应用程序中加载辅助 StoryboardTest.storyboard(在Main.storyboard旁边),如下所示: let storyboard = UIStoryboard(nam
我有情节提要,其中假设Controller1有按钮 当我们按下按钮时,它应该移至下一个控制器,但是我无法访问它。能告诉我如何访问第二个Storybaord,其中一个名为Profile的TabbarCo
这是我在尝试启动主 Storyboard时看到的内容,并且 launchscreen.storyboard 也遇到同样的问题。 当我尝试访问 main.storyboard 时,我看到的是 XML 代
我在 main.storyboard 的 View Controller 中有一个 label1我在 Storyboard的 View Controller 中有另一个名为 Second.storyb
我是一名优秀的程序员,十分优秀!