簡體   English   中英

段中段 - UITableView -

[英]Section within a section - UITableView -

我只是對 tableView 有一個問題。

我知道我們可以返回部分和行的數量。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

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

你能告訴我我怎么能有這樣的東西:

  • 一個部分中的一個部分(如果可能,還有另一個部分) - - 然后在那里配置行?

我會返回什么

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

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

您必須在 cellForRowAtIndexPath 中進行自己的實現,在其中返回實際上由多行組成的行,並且可能是 header label。 或者也許更好的是讓每隔一行成為“標題行”並檢查 cellForRowAtIndexPath 是否在“標題行”或正常行上; 像這樣的東西:

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

當然,在 numberOfRowsInSection 中,對於具有 header 的部分,您必須返回正常的行數 + 1。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM