2010年5月18日火曜日

UITableViewDataSorceプロトコル


Configuring a Table View

例:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  問合せに対し、セクションのインデックスタイトルを配列で返す。インデックスは画面右に一列で表示される。
ex.



- (void)viewDidLoad {
  NSString *path = [[NSBundle mainBundle] pathForResource:@"sortednames" ofType:@"plist"];
  NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
  self.names = dict;
  [dict release];
  NSArray *array = [[names allKeyssortedArrayUsingSelector:@selector(compare:)];
  self.keys = array;
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return keys;
}



ex.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    NSString *key = [keys objectAtIndex:section];
    return key;
}

Inserting or Deleting Table Rows


Reordering Table Rows

0 件のコメント:

コメントを投稿