简体   繁体   English

段中段 - UITableView -

[英]Section within a section - UITableView -

I just have a question with regards to the tableView.我只是对 tableView 有一个问题。

I know we can return the number of sections and rows with.我知道我们可以返回部分和行的数量。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

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

Could you tell me how I can have something like:你能告诉我我怎么能有这样的东西:

  • A section within a section (and another section, if possible) - - And then configure the rows there?一个部分中的一个部分(如果可能,还有另一个部分) - - 然后在那里配置行?

And what would I return in我会返回什么

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

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

You will have to make your own implementation in cellForRowAtIndexPath where you return a row that is really made up of multiple rows and maybe a header label.您必须在 cellForRowAtIndexPath 中进行自己的实现,在其中返回实际上由多行组成的行,并且可能是 header label。 Or maybe better is to make every other row a "header row" and check in cellForRowAtIndexPath whether you are on a "header row" or normal row;或者也许更好的是让每隔一行成为“标题行”并检查 cellForRowAtIndexPath 是否在“标题行”或正常行上; something like this:像这样的东西:

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

and of course in numberOfRowsInSection you will have to return the normal amount of rows + 1 for sections with a header.当然,在 numberOfRowsInSection 中,对于具有 header 的部分,您必须返回正常的行数 + 1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM