2010-10-18 79 views
0

我需要開發一個帶有tableview的rss解析器作爲第一個視圖和詳細視圖,因爲我們在表中選擇一行。實現rss解析器

但事情是,我需要根據發佈日期和titleForHeaderInSection作爲發佈日期將表視圖中的提要分組。那就是應該有很多基於日期的rss feed部分。

隨着各喂有一個發佈日期

我不知道生根粉在tableview中添加部分。

請幫忙。對不起,如果信息不足。

+0

你的問題不在rss解析器上,而是在表視圖中? (或兩者?) – 2010-10-18 07:39:03

+0

不是rss解析器。如何根據日期提供羣組。並將常用日期添加爲部分標題。我正在使用此鏈接的示例。 http://imthi.com/blog/programming/iphone-rss-reader-application-with-source-code.php – xydev 2010-10-18 07:41:47

回答

1

來管理TableView中節的數目使用

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    // Return the number of sections. 
    return noOfSections; 
} 

到計算特定部分

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
     // return no of rows in specific section 
} 

tableView:cellForRowAtIndexPath:方法的行數,同時抽取的部分和從索引路徑排並用它來管理你的數據。

在組使用

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
    // return titleForHeader; 
} 
+0

dat好...是否需要實現下面的方法? (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { – xydev 2010-10-18 08:33:07

+0

no - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)節的方法就足夠了 – Gyani 2010-10-18 08:42:19

+0

ok。那麼相應的行如何移動到它們各自的部分?例如。對於第一部分,可能有5個饋送形成單個部分。第二個派別可能會有另一個沒有。的飼料。等等。 – xydev 2010-10-18 09:02:26

0

可以使陣列的詞典管理標題頭。關鍵將是日期和對象,rss項目的數組。 然後,我將字典鍵排序到一個數組,使日期有序。

在表視圖源委託:

  • numberOfSectionsInTableView:將 日期的排序陣列, 或條目中的 字典
  • 的tableView的nomber在數:titleForHeaderInSection: 將是排序數組中的日期
  • tableView:numberOfRowsInSection:將是字典中用於排序數組項的鍵的rss項的數量
+0

NSSortDescriptor * sortDesc = [NSSortDescriptor sortDescriptorWithKey:@「Pub date」升序:YES]; \t \t [root sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]]; \t \t [self.root sortUsingDescriptors:states];是這樣嗎? – xydev 2010-10-18 08:37:21