2011/04/23

UITableViewのひながた。

UITableViewは便利だ。
普通に使うぶんにはレイアウトはFrameWorkにお任せでOK。
こっちは内部の動きに専念できる。

だが、Delegateの実装が必須になる、これをいちいち覚えておくのは面倒クサイ。
なので、必要最低限のひな形を載せておく。
ただし、ヘッダー側にもそれ用の宣言が必要になる。

以下、ひな形

#pragma mark UITableViewDataSource Implementation
// tableのsection数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}


// section中の行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}


// Cell表示
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return nil;
}


// sectionヘッダタイトル
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return nil;
}


#pragma mark UITableViewDelegate Implementation
// 行選択
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}

0 件のコメント:

コメントを投稿