Книга: iOS. Приемы программирования

Решение

Решение

Используйте свойство accessoryType класса UITableViewCell. Экземпляры этого класса вы предоставляете табличному виду в объекте его источника данных:

— (UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* result = nil;
if ([tableView isEqual: self.myTableView]){
result = [tableView
dequeueReusableCellWithIdentifier: MyCellIdentifier
forIndexPath: indexPath];
result.textLabel.text =
[NSString stringWithFormat:@"Section %ld, Cell %ld",
(long)indexPath.section,
(long)indexPath.row];
result.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
return result;
}
— (NSInteger) tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section{
return 10;
}
— (void)viewDidLoad{
[super viewDidLoad];
self.myTableView = [[UITableView alloc]
initWithFrame: self.view.bounds
style: UITableViewStylePlain];
[self.myTableView registerClass: [UITableViewCell class]
forCellReuseIdentifier: MyCellIdentifier];
self.myTableView.dataSource = self;
self.myTableView.autoresizingMask =
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
[self.view addSubview: self.myTableView];
}

Оглавление книги

Оглавление статьи/книги

Генерация: 0.053. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз