问题描述
我在 Xcode 6 中新引入的自适应故事板遇到了一些麻烦.iPhone 应用程序已经完成,现在我想用它创建一个通用应用程序.假设我有一个显示一些单元格的 viewcontroller
和一个显示单元格详细信息的细节 viewcontroller
.
I've some troubles with the newly introduced adaptive storyboard in Xcode 6.The iPhone App is finished and now I want to create a universal app out of it.Let's assume I've a viewcontroller
that displayes some cells and a detail viewcontroller
in which the details of the cells are displayed.
在 iPhone 上:当我点击单元格时,我有一个 push segue
到详细信息视图.在 iPad 上:我想要一个 modal segue
而不是 push.
On iPhone: When I click the cell I've a push segue
to the detail view.On iPad: I would like to have a modal segue
instead of a push.
我可以在 prepareForSegue
中或以其他方式更改此设置吗?
Can I change this in the prepareForSegue
or somehow else?
我找到了一种方法……但我对此并不完全满意.如果有人有更好的解决方案,请告诉我...
我做了两个 segue 并在代码中区分.
I made two segues and distinguish it in the code.
if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
self.performSegueWithIdentifier(kSegueToDetailModal, sender: object)
}
else if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
self.performSegueWithIdentifier(kSegueToDetail, sender: object)
}
推荐答案
你可以有两个 segues 并按照你的建议在代码中区分,但我建议使用自适应大小类来确定你想要哪个 segue 而不是 userInterfaceIdiom代码>.通过这种方式,您还可以在 iPhone 6 Plus 和 iPad 等横向模式下使用模态转场.
You can have two segues and distinguish in code as you suggest, but I recommend using adaptive size classes to determine which segue you want rather than the userInterfaceIdiom
. This way you could also use the modal segue with, for example, the iPhone 6 Plus in landscape orientation as well as iPad.
这篇关于Xcode 6 Adaptive Storyboard 每个设备的不同 Segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!