gpt4 book ai didi

swift - 仅更改 iPad 的表格 View 单元格高度

转载 作者:行者123 更新时间:2023-11-28 11:09:47 24 4
gpt4 key购买 nike

我想知道该怎么做...我只想更改 iPad 尺寸的表格 View 单元格高度。当我尝试使用 Size Classes 更改它时,它会针对每个设备进行更改,而不仅仅是我所在的设备。我是否必须创建一个全新的 Storyboard,或者是否有办法通过代码或自动布局来拥有2 种不同的 tableview 单元格高度 - 一种用于 iPhone,一种用于 iPad。我也在 xcode 中使用 swift

谢谢!

最佳答案

您可以使用 userInterfaceIdiom 来查明该应用程序是否正在 iPad 上运行

switch UIDevice.currentDevice().userInterfaceIdiom {
case .Phone:
// It's an iPhone
case .Pad:
// It's an iPad
case .Unspecified:
// Something undefined
}

或者,您也可以使用屏幕的 UITraitCollection

let deviceIdiom = UIScreen.mainScreen().traitCollection.userInterfaceIdiom

switch (deviceIdiom) {
case .Pad:
// It's an iPad
case .Phone:
// It's an iPhone
case .TV:
// It's a AppleTV
default:
// Who knows
}

关于swift - 仅更改 iPad 的表格 View 单元格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35854949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com