0

次のような例外があります。

Thread 1: EXC_Breakpoint (code = EXC_I386_BPT,subcode=0x0)

私のストーリー ボードには、3 つのコントローラーがあります。ナビゲーションコントローラー、UIViewController、そしてテーブルビューコントローラー。アプリの初回起動時に UIViewController が表示されます。Core Data DB にいくつかのものを追加します。次に、このコントローラー自体に「レコードの確認」バーボタンがあります。それをクリックして、3 番目のコントローラーである tableviewcontroller に移動します。ここで、その日に追加した記録を見ることができます。追加したばかりのものをクリックし、次のように NSNotifications を使用して UIviewcontroller 画面に戻ります。

//This code is in tableviewcontroller.didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ITMAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.salesOrderObject = [self.salesOrdersArray objectAtIndex:indexPath.row];

    NSNotification *notification =[NSNotification notificationWithName:@"reloadRequest"
                                                                object:self];
    [[NSNotificationCenter defaultCenter] postNotification : notification];

    [self.navigationController popViewControllerAnimated:YES];
}

私の ViewController viewDidLoad では、通知をリッスンするためにこのコードを書きます。

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(newReloadData)
                                             name:@"reloadRequest"
                                           object:nil];


-(void)newReloadData
{
self.salesOrder =  self.appDelegate.salesOrderObject; //self.reloadedSOObject; //appDelegate.salesOrderObject;

if(self.salesOrder !=nil)
{
//I add UItextviews,textfields,buttons etc here to a scrollview.
ITMCustomView *cView = [[ITMCustomView alloc] initWithFrame:CGRectMake(187, 660, 400, 400)
                                                     andOrderedItem:@"New"
                                                             andTag:self.tagNumber
                                                      withFoldArray:self.foldTypeArray
                                                      withRollArray:self.rollTypeArray];

        cView.tag =self.tagNumber;
        NSLog(@"Assigned tag is %d",cView.tag);

        cView.delegate = self;

        //[self.scrollView addSubview:customView];

        //self.scrollView.contentSize = CGRectMake(187, 660, 400, 400).size;


        CGPoint scrollPoint = CGPointMake(0.0, (cView.frame.origin.y/500)*400);
        [self.scrollView setContentOffset:scrollPoint animated:YES];

        [self.scrollView addSubview:cView];

        CGFloat scrollViewHeight = 0.0f;
        for (UIView *view in self.scrollView.subviews)
        {
            scrollViewHeight += view.frame.size.height;
        }

        CGSize newSize = CGSizeMake(320,scrollViewHeight);
        //CGRect newFrame = (CGRect){CGPointZero,newSize};
        [self.scrollView setContentSize:newSize];
        NSLog(@"750 the tag number is %d",self.tagNumber);
        NSLog(@"the scroll view height is %f",scrollViewHeight);
        self.currentCGRectLocation = cView.frame;
}
}

スクロール ビューに何かを追加するときに例外が発生するかどうかを考えています。または、スタック オーバーフローをさらに調べたときに、デリゲートまたは NSnotification が原因である可能性があります。例外が発生する理由と場所がわかりません。このコード行を書くと、この例外が発生しますか?

[self.navigationController popViewControllerAnimated:YES];

この質問はこの質問の拡張です UIScrollview に Customview を追加すると、スクロール時に画面がスタックする

この例外がどこでどのように発生するのかわかりません。さらに情報が必要な場合は、お問い合わせください。ありがとう...

4

1 に答える 1

1

通知センターを呼び出すとnewReloadData 、通知センター@"reloadRequest"にメソッドを含む文字列が 含まれているクラスがnewReloadDataそれを実行する必要があるため、最初にビューをポップしてから通知を呼び出す必要があります。

回線の順序を変更してみてください。最初[self.navigationController popViewControllerAnimated:YES];に電話してから電話してください。[[NSNotificationCenter defaultCenter] postNotification : notification];

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ITMAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.salesOrderObject = [self.salesOrdersArray objectAtIndex:indexPath.row];

    NSNotification *notification =[NSNotification notificationWithName:@"reloadRequest"
                                                                object:self];
    //here first pop view
    [self.navigationController popViewControllerAnimated:YES];

    //then send notification before scopes end
    [[NSNotificationCenter defaultCenter] postNotification : notification];


}
于 2012-12-26T19:17:40.473 に答える