2

* Collection was mutated while being enumerated を表示してアプリがクラッシュすること がありました。これは常に同じコード行で発生しています。この問題について助けてください。私はこれにこだわった。私のコードのView Controller行をプッシュすると、アプリがクラッシュしますが、頻繁ではありません。私のエラーコンソール

キャッチされていない例外 'NSGenericException' が原因でアプリを終了しています。理由: ' *コレクション CALayerArray: 0x1030c730 が列挙中に変更されました。""、""、""、""、""、""、""、""、""、""、""、""、""、""、""、""、"" , "" )'

私のコード:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
 ServiceDetails *service=[[ServiceDetails  alloc] initWithNibName:@"ServiceDetails"   bundle:nil];  
    CompanyListingForm *list=[[CompanyListingForm  alloc]initWithNibName:@"CompanyListingForm" bundle:nil];
[category_company_text resignFirstResponder];
if(viewHoldingTable)
{
    [viewHoldingTable removeFromSuperview];
}
if (category_clicked_flag==0) {
    if (location_or_cat_com==0) {
        NSMutableArray *get=[district_array objectAtIndex:indexPath.row];
        locationid=[[get objectAtIndex:0]intValue];
        [location_textfield resignFirstResponder];
        location_textfield.text=[get objectAtIndex:1];
    }
    else
    {
        if (draggingView) {
            [draggingView removeFromSuperview];

        }
        if (viewHoldingTable) {
            [viewHoldingTable removeFromSuperview];
        }


        NSMutableArray *get=[company_array objectAtIndex:indexPath.row];
        category_company_text.text=[get objectAtIndex:1];



        service.ida=[NSString stringWithFormat:@"%d",[[get objectAtIndex:0] intValue]];

        service.idloc=[NSString stringWithFormat:@"%d",locationid];



        [self.navigationController pushViewController:service animated:YES];//getting error at this point.

        //[emer release];   
    }
}
else
{
    if (location_or_cat_com==0) {
        NSMutableArray *get=[district_array objectAtIndex:indexPath.row];
        locationid=[[get objectAtIndex:0]intValue];
        [location_textfield resignFirstResponder];
        location_textfield.text=[get objectAtIndex:1];
    }
    else
    {
        NSMutableArray *get=[category_array objectAtIndex:indexPath.row];
        category_company_text.text=[get objectAtIndex:1];
        int catid=[[get objectAtIndex:0]intValue];

        list.IDForLoc=[NSString stringWithFormat:@"%d",locationid];
        list.IDForCat=[NSString stringWithFormat:@"%d",catid];
        list.companydetails=[get objectAtIndex:1];
        [self.navigationController pushViewController:list animated:YES];//getting error at this point.

    } 
}
 [service release];
 [list release];
}
4

1 に答える 1

1

問題は、View Controllerをプッシュするように要求しているのと同時に、これらすべてをインターフェースに対して行っていることだと思います。インターフェイスに他の変更が落ち着くまでの時間を与えるために、たとえば 0.1 秒の遅延で、pushViewController行をブロックでラップしてみてください。dispatch_afterまたは、別の方法で行いremoveFromSuperviewます。ものを遅延に入れます。さらに良いことに、スーパービューから削除されるものが後で削除されるように、何らかのフラグをスローしviewWillAppearます。今はする必要はありません。とにかく、プッシュされたView Controllerでこのビューをカバーするために非表示にしようとしています。

于 2012-11-28T05:11:40.907 に答える