gpt4 book ai didi

ios - UITableViewController 的静态内容消失了

转载 作者:行者123 更新时间:2023-11-29 02:41:35 24 4
gpt4 key购买 nike

我已经多次犯过这个错误,所以我想我应该分享解决方案。当我将一个模拟的 iOS 应用程序转换为一个真实的应用程序时,它经常发生。当我模拟时,我在 Xcode 中使用 Storyboard,而没有将 sublcasses 分配给 UIViewControllers。但是,当我对设计感到满意时,我会开始编写代码,然后在创建子类并将它们分配给 Storyboard 屏幕后。

我遇到的一个常见问题是,当我分配子类时,我的 UITableViewController 屏幕的静态内容消失了。

重现问题的步骤:

  1. 将 TableViewController 拖到 Storyboard上
  2. 将内容设置为静态单元格
  3. 作为原型(prototype)制作的一部分填充一些静态单元格
  4. 当您对原型(prototype)子类 UITableViewController 感到满意时
  5. 转到 Utilities=>Identity Inspector 并将自定义类设置为您的子类

此时,当我在模拟器中运行项目时,屏幕上的静态内容已经消失。

最佳答案

这是上面序列中缺少的步骤。

  1. 删除 Xcode 创建子类时生成的代码

要删除的代码:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 0;
}

在需要将内容从静态单元格更改为动态单元格之前,您需要保留此代码。

关于ios - UITableViewController 的静态内容消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25705558/

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