動的 UITableView に供給される 2 つの異なるタイプのデータの間に記号を入れようとしています。データを 2 つのセクションに分割することはできますか?それとも、分割をマークするために、userInteractionEnabled 以外のセルを入力する必要がありますか? numberOfSections プロパティをプログラムで設定できません。これを回避する方法を知っている人はいますか?
質問する
1803 次
1 に答える
1
あなたがしようとしているのは、グループ化されたテーブルビューを作成することです。インターフェースビルダーで、テーブルビューにグループ化されたテーブルビューオプションを選択したことを確認してください
次に、次のようなグループ化されたテーブル ビュー メソッドを呼び出します。
// for sections I guess you want 2 sections
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
if(section==0)
return [yourdatasource count]; // make sure that each section is returned here
if(section==1)
return [anotherdatasource count];
}
// set header height of gropued tableview
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
return 60.0; // choose your height for each section
}
//set header section labels
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
}
私のコードはテストされていません。
詳細については 、このhttp://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/を参照してください。
于 2013-01-23T20:37:51.827 に答える