我正在处理具有搜索视图的应用程序,搜索视图包含一个带有 3 个部分的 tableView - 我通过手动实现该部分
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 3;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 0){
UITextField *title = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
[title setBackgroundColor:[UIColor lightGrayColor]];
[title setTextAlignment:UITextAlignmentRight];
[title setFont:[UIFont boldSystemFontOfSize:15]];
[title setText:@"videos"];
return title ;
}
if (section == 1){
UITextField *title = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
[title setBackgroundColor:[UIColor lightGrayColor]];
[title setTextAlignment:UITextAlignmentRight];
[title setFont:[UIFont boldSystemFontOfSize:15]];
[title setText:@"documents"];
return title ;
}
if (section == 2){
UITextField *title = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
[title setBackgroundColor:[UIColor lightGrayColor]];
[title setTextAlignment:UITextAlignmentRight];
[title setFont:[UIFont boldSystemFontOfSize:15]];
[title setText:@"questions"];
return title ;
}
}
现在,我使用 XML 接收的所有数据如下所示:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>documents</title>
<item>
<title>how to count the days</title>
<link>some link...</link>
<date>11/09/2007 16:45:00</date>
<SupplierName>roei</SupplierName>
<CategoryName>the omer</CategoryName>
</item>
<item>
<title>research</title>
<link>some link...</link>
<date>16/05/2010 13:41:00</date>
<SupplierName>eran</SupplierName>
<CategoryName>shavoot</CategoryName>
</item>
</channel>
<channel>
<title> video </title>
<item>
<title>the end of holiday</title>
<link>some link...</link>
<date>06/06/2011 08:56:00</date>
<SupplierName>dina</SupplierName>
<CategoryName>shavoot</CategoryName>
</item>
<item>
<title>bible</title>
<link>some link...</link>
<date>24/05/2012 10:00:00</date>
<SupplierName>amir</SupplierName>
<CategoryName>shavoot</CategoryName>
</item>
</channel>
<channel>
<title>questions</title>
<item>
<title>questions for shavvot</title>
<link>some link...</link>
<date>28/10/2008 13:31:00</date>
<SenderName>אלי.ד.</SenderName>
<CategoryName>holidays</CategoryName>
</item>
<item>
<title>Shavoot</title>
<link>some link...</link>
<date>25/05/2008 01:01:00</date>
<SenderName>amir</SenderName>
<CategoryName>holidays</CategoryName>
</item>
</channel>
</rss>
如您所见-我的标题带有部分的名称,但是我应该如何确定单元格的正确部分?我将所有数据解析为一个数组,然后使用字典将其取出:
NSDictionary *object = [ResultsArrayDisplay objectAtIndex:indexPath.row];
请帮助我,我经过几个小时的尝试,到目前为止在互联网上没有任何帮助。