2011-02-17 69 views

回答

0

嗯。我想你可以在sectionIndexTitlesForTableView計算總和爲這樣:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 
{ 
    // replace the following with however you'll calculate the sums 
    int sumSectionOne = 4; 
    int sumSectionTwo = 3; 

    return [NSArray arrayWithObjects:[NSString stringWithFormat:@"$%d",sumSectionOne], [NSString stringWithFormat:@"$%d",sumSectionTwo], nil]; 
} 

但它意味着你將在該表視圖調用reloadSections很多。此外,這不完全是UITableView的預期目的(儘管承認這是一個非常簡單的方法)。

0

有沒有那種削減這一點,你需要實現一個良好的存儲數據,然後結構法邏輯來獲取them.so它的所有關於邏輯,看看我的做法。

你需要將這個記錄添加到字典形式的數組中,這意味着用兩個不同的關鍵字「基金」和「金錢」(任何事物)在字典中添加資金。

當你使節代表titleForHeaderInSection方法時,你需要實現邏輯。你需要使循環達到數組數並訪問字典並添加所有「金錢」值。

現在你需要執行。如果你面對代碼中的任何問題,然後再次問。

相關問題