2011-05-04 42 views
0

我有一個帶有搜索欄(搜索顯示控制器)的表格視圖我需要組織結果的部分...在開始時有1個部分和搜索結果,他們可以有1或2或3節...你有一個很好的方法來做到這一點?在UITableView中組織搜索控制器的結果

謝謝!

+0

這可能有助於某人http://stackoverflow.com/a/39388169/2033377 – 2016-09-08 10:39:56

回答

0

取決於您如何捕獲您的搜索結果。

通常你會想要NSArray的NSMutableArray。這樣,你的主要array.count就成爲你的部分數量,並且行數將成爲該indexpath上的嵌套數組的數量。 NSDictionaries數組也是典型的。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

    return [mainArray count]; 
} 

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

    return [[mainArray objectAtIndex:section] count]; 

} 
相關問題