iphone - 如何在 UITableView 的开头插入 UITableViewCell

标签 iphone ios uitableview

我正在尝试设置一个 UITableView,其中包含 x 个部分和每个部分的 X 行数。

但是我想在 UITableView 的顶部添加一行,有没有办法将其硬编码到 View 中?

我目前根据 NSdictionary 返回部分的数量和每个部分的行数,如下所示。

- (NSInteger)numberOfSectionsInTableView: (UITableView *)tableView
{
    // Return the number of sections.
    return [letterDictionary count];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // returns the number of rows per section based off each entry in letterDictionary   
    currentLetter = [sectionLetterArray objectAtIndex:section];
    return [[letterDictionary objectForKey:currentLetter] count];       
}

最佳答案

您可以向表格 View 添加“标题”。

在你的tableview类中:

self.tableView.tableHeaderView = yourView;

关于iphone - 如何在 UITableView 的开头插入 UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12045786/

相关文章:

iphone - 导航 Controller 上的编辑按钮不进入编辑模式

iphone - 当 If() 运行时阻止 UIAnimation 不被调用

ios - 解析后端上传文件的新错误 - 错误 : File name must be a string - PFFile

ios - 用于本地化 IOS 应用程序的按钮

swift - 如何更改一个表格 View 单元格的分隔符颜色?

iphone - 如何通过网络更新 iOS 应用程序

ios - 不同设备的不同设置?

ios - Swift 3.0 无法从 UITableView 中删除行

iphone - 为什么我的 UITableView 在异步重新加载数据期间滚动时会失去流动性?

ios - NSString在时间之前释放