我们正在使用Swift开发iOS应用程序。 我们有一个tableView,其中每个TableCell都是可扩展的。
它目前看起来像这样。 (忽略时间标签的缩写,这不是预期的)
在平板电脑上执行时,扩展子单元格中的标签应移动到父单元格,具体取决于可用空间大小。 如果我们必须为平板电脑和手机制作一个单独的场景,那将不会是一个问题。
如果我们可以直接在界面构建器中更改这些场景的显示,这将是美丽的,具体取决于在底栏上选择的设备。
实现这一目标的最佳(最干净)方法是什么?
提前致谢。
We are developing an iOS app using Swift. We have a tableView where each TableCell is expandable.
It currently looks like this. (Ignore the abbreviation of the time label, this is not intended)
When executed on a tablet the labels from the expanded sub cell should be moved to the parent cell, depending on how much space is available. It would not be a problem if we have to make a separate scene for tablets and phones.
It would be beautiful, if we could change the display of those scenes directly in the interface builder, depending on which device is selected on the bottom bar.
What is the best (cleanest) way to achieve that?
Thanks in advance.
最满意答案
您需要的声音听起来像Xcode 8中的“各种特性”选项,它允许您根据设备(实际上基于宽度和高度设置)对同一视图进行不同的配置,但在使用时缩小到设备范围,如果您点击Xcode中的变化特征按钮,您将看到W和H的各种选项,您可以实时查看设备如何根据您的选择而变化。 只是要小心一点,当你引入一个新设置时,你使用了变化的特征按钮,但之后你可以正常地从右侧选择器访问它。
您将在Xcode 8中看到一些属性旁边有一个小+号,这是您在介绍它们之后会发现它们的不同特征的地方,它需要一些习惯,但是一旦你了解它就非常强大。 它也是在iOS中制作自适应应用程序的推荐方法
What you need sounds like the "vary for traits" option in Xcode 8, it allows you to have different configurations of the same view depending on the device(actually based on Width and Height settings) but it narrow down to device as you use it, if you click the vary for traits button in Xcode you will see the various options for W and H and you can see in real time how the devices changes depending on your selection. Just be a little bit careful about one thing, when you introduce a new setting you use the vary for traits button but after that you access it from the right hand side picker as normal.
You will see in Xcode 8 that some attributes have a small + sign next to them, that is where you will find your different traits after you have introduced them, it takes some getting used to but is very powerful once you get your head around it. It is also the recommended way to make adaptive applications in iOS
更多推荐
发布评论