検索ビューを持つアプリケーションで作業している場合、検索ビューには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>
ご覧のとおり、セクションの名前が付いたタイトルがありますが、セルの正しいセクションをどのように決定する必要がありますか?すべてのデータを1つの配列に解析し、辞書を使用して取得します。
NSDictionary *object = [ResultsArrayDisplay objectAtIndex:indexPath.row];
私を助けてください、これまでのところインターネットで何も役に立たなかった数時間の試行の後のim。