K.W. K.W. - 1 month ago 7
iOS Question

UITableView Section with Index

Anything I missed in the following code? I can create a list but the list is array x26 times (26x section) in the

UITableView
. A list shown, but the section title is only point to 'A'

enter image description here

arr_indexpeople
> An array of A,B,C,D,E.....Z

arr_completeArray
> An array of a list of people

Thank you.

Answer

The datasource method will get called for every section to load, so give the dynamic index of a section as input variable for arr_indexpeople as shown below.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
  return [arr_indexpeople objectAtIndex:section]
}
Comments