iphone - 一个部分中的一个部分 - UITableView -

标签 iphone objective-c xcode uitableview

我只是有一个关于 tableView 的问题。

我知道我们可以返回节数和行数。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

你能告诉我怎样才能拥有这样的东西吗:

  • A section within a section (and another section, if possible) - - And then configure the rows there ?

我会返回什么

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

最佳答案

您将必须在 cellForRowAtIndexPath 中进行自己的实现,您返回的行实际上由多行组成,可能还有一个标题标签。或者更好的办法是让每隔一行成为“标题行”,然后在 cellForRowAtIndexPath 中检查你是在“标题行”还是普通行上;像这样:

if (indexPath.row == 0) {
     // return header row
} else {
     // return normal row
}

当然,在 numberOfRowsInSection 中,对于带有标题的部分,您必须返回正常的行数 + 1。

关于iphone - 一个部分中的一个部分 - UITableView -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6280246/

相关文章:

objective-c - StoryBoard 2 导航 Controller 指向相同的 View

objective-c - 在动态创建的类中执行协议(protocol)类方法

ios - 不断在两个 View Controller iOS 之间传递数据

ios - 停止更新 map 查看位置

ios - Xcode 在打开 .xcodeproj 文件时崩溃

iphone - 用于剥离 HTML 标记的 NSRegularExpression

ios - 设计 UITableView/Cell - iOS

iphone - 我无法对我的 iOS 应用程序进行代码签名

ios - 使用自动布局调整按钮大小

c++ - XCode 未显示 C++ 程序中的泄漏