【问题标题】:detailTextLabel.text not showing, on iPhone 5 onlydetailTextLabel.text 不显示,仅在 iPhone 5 上
【发布时间】:2013-01-05 16:37:37
【问题描述】:

我已经解决了这个问题,但值得分享,因为我在这方面找不到任何东西。

我有一个 UITableView 的子类,但没有显示 detailTextLabel.text。 detailTextLabel 对象本身正常存在,并且包含文本,您只是在屏幕上看不到它。

该错误仅发生在 iPhone 5 或视网膜 4 英寸模拟器上。在 iPod 4 或任何其他模拟器“硬件”上都可以。使用的 iOS 版本没有区别。

答案如下。

【问题讨论】:

    标签: ios xcode iphone-5 viewdidload detailtextlabel


    【解决方案1】:

    通过让触发违规表格显示的视图控制器在 viewWillAppear 而不是 viewDidLoad 中执行此操作来修复它。

    -(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        //Used to do this in viewDidLoad, but that stopped the detailTextLabel showing
        //for this table view on the iPhone 5. If do it from here, it's fine.
        [friendsSubView addSubview:friendsTableViewController.view];
    }
    

    【讨论】:

      【解决方案2】:

      以下应该是正确的代码吗? [friendsSubView addSubview:friendsTableViewController.tableView];

      【讨论】:

      • 不,我将正确的代码复制并粘贴到我的答案中。有用。唯一的问题是它是在 viewDidLoad 而不是 viewWillAppear 中调用的。
      猜你喜欢
      • 2015-01-29
      • 1970-01-01
      • 2012-10-17
      • 1970-01-01
      • 1970-01-01
      • 2015-08-02
      • 1970-01-01
      • 2015-01-01
      • 2014-12-24
      相关资源
      最近更新 更多