Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.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 导航控制器中选项卡栏控制器下的数组索引混乱_Iphone_Objective C_Ios - Fatal编程技术网

Iphone 导航控制器中选项卡栏控制器下的数组索引混乱

Iphone 导航控制器中选项卡栏控制器下的数组索引混乱,iphone,objective-c,ios,Iphone,Objective C,Ios,因此,我有一个应用程序,它将导航控制器嵌入到选项卡栏控制器中。我有一个NSMutableArray,从中获取数据 问题是,当表格视图出现时,我点击其中一个,细节视图出现,但模式非常混乱。如果我第一次单击单元2,将显示单元2详细视图。如果单击“上一步”并再次单击单元格2,则不会显示详细视图,然后单击单元格3时,将显示单元格2的详细视图。每次我点击导航时,它都会继续改变订单。我可能做错了什么?这里有一些代码可以帮助您: #pragma mark - View lifecycle methods -

因此,我有一个应用程序,它将导航控制器嵌入到选项卡栏控制器中。我有一个NSMutableArray,从中获取数据

问题是,当表格视图出现时,我点击其中一个,细节视图出现,但模式非常混乱。如果我第一次单击单元2,将显示单元2详细视图。如果单击“上一步”并再次单击单元格2,则不会显示详细视图,然后单击单元格3时,将显示单元格2的详细视图。每次我点击导航时,它都会继续改变订单。我可能做错了什么?这里有一些代码可以帮助您:

#pragma mark - View lifecycle methods
- (void)viewDidLoad
{
    [super viewDidLoad];
    searchResultsArray = [[NSMutableArray alloc] initWithObjects:@"Producer 1", @"Producer 2",@"Producer 3", nil];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                       reuseIdentifier:CellIdentifier] autorelease];



    cell.textLabel.text = [searchResultsArray objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{

    NearMeDetailViewController *nmdvController = [[NearMeDetailViewController alloc] initWithNibName:@"NearMeDetailViewController" bundle:nil];

    NSLog(@"%i", indexPath.row);

    nmdvController.producerName = [searchResultsArray objectAtIndex:indexPath.row];

    NSLog(@"%@", [searchResultsArray objectAtIndex:indexPath.row]);

    [self.navigationController pushViewController:nmdvController animated:YES];
    [nmdvController release];
}

您已添加并在取消选择时将其推送到导航控制器

何时取消选择?同时选择另一个

例如:

您必须首先选择cell1。确定吗

然后

选择单元格2

所以现在cell1将首先取消选择,然后选择cell2

您正在将代码放入取消选择。因此,它将在下一个单元格或其他单元格选择中推送每一次

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

}

not

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{

}

请让我知道resultyup,就是这个。我很痛苦地看到,我的错误一直都是额外的“德”