Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何通过单元格导航到UITableView位置,以及如何使用索引将其标题导航到UITableView位置_Iphone_Uitableview_Indexing - Fatal编程技术网

Iphone 如何通过单元格导航到UITableView位置,以及如何使用索引将其标题导航到UITableView位置

Iphone 如何通过单元格导航到UITableView位置,以及如何使用索引将其标题导航到UITableView位置,iphone,uitableview,indexing,Iphone,Uitableview,Indexing,我使用的是一个UITableView,里面有大约200个单元格,其中包含标题、副标题和缩略图。我想有一个选择方法,就像苹果的联系人应用程序一样,你可以从字母表中选择一个字符 我正在绘制选择界面A、B、C等,并通过其委托检索相应的索引和标题,即:A=1、B=2、C=3等 现在我想导航到第一个单元格,其中单元格标题的第一个字符以选定的索引字符开头。就像联系人应用程序一样 有人能给我一个如何实现这些功能的方向吗 - (NSInteger)tableView:(UITableView *)tableVi

我使用的是一个UITableView,里面有大约200个单元格,其中包含标题、副标题和缩略图。我想有一个选择方法,就像苹果的联系人应用程序一样,你可以从字母表中选择一个字符

我正在绘制选择界面A、B、C等,并通过其委托检索相应的索引和标题,即:A=1、B=2、C=3等

现在我想导航到第一个单元格,其中单元格标题的第一个字符以选定的索引字符开头。就像联系人应用程序一样

有人能给我一个如何实现这些功能的方向吗

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
我用表格填写了我的分区索引

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

    if(searching)
        return nil;

    NSMutableArray *tempArray = [[NSMutableArray alloc] init];
    [tempArray addObject:@"A"];
    [tempArray addObject:@"B"];
    [tempArray addObject:@"C"];
    [tempArray addObject:@"D"];
    [tempArray addObject:@"E"];
    [tempArray addObject:@"F"];
    [tempArray addObject:@"G"];
    [tempArray addObject:@"H"];
    [tempArray addObject:@"I"];
    [tempArray addObject:@"J"];
    [tempArray addObject:@"K"];
    [tempArray addObject:@"L"];
    [tempArray addObject:@"M"];
    [tempArray addObject:@"N"];
    [tempArray addObject:@"O"];
    [tempArray addObject:@"P"];
    [tempArray addObject:@"Q"];
    [tempArray addObject:@"R"];
    [tempArray addObject:@"S"];
    [tempArray addObject:@"T"];
    [tempArray addObject:@"U"];
    [tempArray addObject:@"V"];
    [tempArray addObject:@"W"];
    [tempArray addObject:@"X"];
    [tempArray addObject:@"Y"];
    [tempArray addObject:@"Z"];

    return tempArray;
}
试试这个:-

#pragma mark -
#pragma mark UITableView data source and delegate methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [contactArr count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    /*
     If the requesting table view is the search display controller's table view, return the count of the filtered list, otherwise return the count of the main list.
     */
        return [[[contactArr objectAtIndex:section]objectForKey:@"name"] count];

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0f;
}

#pragma mark -

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
        return [[contactArr objectAtIndex:section]objectForKey:@"char"];

}

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

    NSMutableArray *tempArray = [[NSMutableArray alloc] init];
    [tempArray addObject:@"A"];
    [tempArray addObject:@"B"];
    [tempArray addObject:@"C"];
    [tempArray addObject:@"D"];
    [tempArray addObject:@"E"];
    [tempArray addObject:@"F"];
    [tempArray addObject:@"G"];
    [tempArray addObject:@"H"];
    [tempArray addObject:@"I"];
    [tempArray addObject:@"J"];
    [tempArray addObject:@"K"];
    [tempArray addObject:@"L"];
    [tempArray addObject:@"M"];
    [tempArray addObject:@"N"];
    [tempArray addObject:@"O"];
    [tempArray addObject:@"P"];
    [tempArray addObject:@"Q"];
    [tempArray addObject:@"R"];
    [tempArray addObject:@"S"];
    [tempArray addObject:@"T"];
    [tempArray addObject:@"U"];
    [tempArray addObject:@"V"];
    [tempArray addObject:@"W"];
    [tempArray addObject:@"X"];
    [tempArray addObject:@"Y"];
    [tempArray addObject:@"Z"];

    return tempArray;
//    return [[NSArray arrayWithObject:UITableViewIndexSearch] arrayByAddingObjectsFromArray:
//            tempArray];

}

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
//  if (title == UITableViewIndexSearch) {
//            [tableView scrollRectToVisible:self.searchDisplayController.searchBar.frame animated:NO];
//            return -1;
//        } else {
            return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];

}

你能更清楚地说明你想做什么吗?你的问题对我来说太不清楚了。谢谢你,正是我想要的。我只需要把我放置的数据分开,这样我就有了26个不同的部分!