私のコードは他とは少し異なりますが、動作します。Xcodeでグループ化されたテーブルビューにセクションを追加する
私はアプリのコーディングに新しいですが、私はセクションに これらのいくつかを追加したい:
だから、それらのいくつかは、それぞれに小さなタイトルと自分のグループを持っています。
しかし、私のコードは次のようになります。
と私は右のそれを行うに挿入するのか分かりません。
(その画像の下半分を使用すると、テーブルビューから何かを選択すると、詳細ビューに表示されていることを、詳細ビュー内の画像である。)
(私は、Xcodeのは、私のコード内のエラーを示して知っていますそれでも動作します)。
誰でも助けてくれますか?あなたが好きなものと
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//Here you must return the number of sectiosn you want
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//Here, for each section, you must return the number of rows it will contain
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
//For each section, you must return here it's label
if(section == 0) return @"header 1";
.....
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.text = // some to display in the cell represented by indexPath.section and indexPath.row;
return cell;
}
は、あなたがあなたのデータを配置することができます:一つの配列をあなたには、いくつかのUITableView方法とデリゲートメソッドを実装する必要が
ありがとうございます!私はヘッダーを持っていますが、ヘッダーの下にデータはありません。スクリーンショット:http://cl.ly/3M1J230W0r0T0844102X – ifraaank
@ user1036372:あなたのtableViewコードを与えて、私は見てみましょう。これは、numberOfRowsInSectionの戻り値が不正であるか、不正なcellForRowAtIndexPathの解析のためにbebする必要があります – Oliver