【问题标题】:UITableviewCell show extra label in when device in landscapeUITableviewCell 在横向设备时显示额外的标签
【发布时间】:2017-03-02 13:25:51
【问题描述】:

我正在努力实现以下目标:

  • 在 UITableViewCell 中,我有一个带有 3 个标签的 StackView,但我只想纵向显示其中两个,而在横向模式下全部显示。

我尝试做的是:为 installed 属性添加一个自定义,该属性仅在设备处于 CxC 时检查...但是当我运行应用程序并旋转模拟器时,我得到这在调试中:待定:从 NSPoint: {36.5, 15} 到 Optional(NSPoint: {40.5, 15})的位置

我附上了一张图片,展示了我想要实现的目标。

非常感谢]1

【问题讨论】:

    标签: uitableview ios10 tableviewcell ios-autolayout


    【解决方案1】:

    您可以通过获取设备方向状态并隐藏第三个标签来找到方向

     if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft{
        cell.thirdLabel.hidden = false
        }
        else if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight{
        cell.thirdLabel.hidden = false
    
        }
        else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortraitUpsideDown{
        cell.thirdLabel.hidden = true
        }
        else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortrait{
       cell.thirdLabel.hidden = true
        }
    

    你可以使用这两个并删除其他的

    【讨论】:

    • 您好...我已经尝试了您的代码,但仍然无法正常工作...仍然得到 _ 待处理:从 NSPoint: {36.5, 15} 到 Optional(NSPoint: {40.5, 15})_ 旋转设备时...
    • 如果您使用任何库,请将它们更新到最新版本,如果您使用动画,请检查它们是否在两种模式下兼容,否则更新。
    • 感谢您的回答...不使用动画,所有库都已更新(领域)
    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 2016-03-13
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    相关资源
    最近更新 更多