Iphone 调用sectionIndexTitlesForTableView

Iphone 调用sectionIndexTitlesForTableView,iphone,uitableview,Iphone,Uitableview,无法从作为UITableViewController子类的viewcontroller中调用此方法吗 我正在尝试: NSString *key = [[self sectionIndexTitlesForTableView] objectAtIndex: section]; 但我收到编译器警告,说明viewcontroller可能不会响应此方法 请参阅Apple文档,它似乎是UITableViewDataSource的可选成员 然后 您不能在任何对象上调用它,只能在类中实现它… //

无法从作为UITableViewController子类的viewcontroller中调用此方法吗

我正在尝试:

 NSString *key = [[self sectionIndexTitlesForTableView] objectAtIndex: section];

但我收到编译器警告,说明viewcontroller可能不会响应此方法

请参阅Apple文档,它似乎是
UITableViewDataSource的可选成员
然后

您不能在任何对象上调用它,只能在类中实现它…

    // Asks the data source to return the titles for the sections for a table view.

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
因此,在确认
UITableViewDataSource
协议的类中使用以下命令

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
      {

      }
看看苹果的文档


tableviewcontroller的委托方法。所以每次重新加载表时都会调用它。所以这不是正确的方法(NSInteger)tableView:(UITableView*)tableView行数section:(NSInteger)section{NSString*key=[[self-sectionIndexTitlesForTableView]objectAtIndex:section];return[[self-countryDicts]objectForKey:key]count];}-(NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView{return[self.countryDicts allkey];}