0

问题:我不断收到 EXC_BAD_ACCESS。在我打开 NSZombieEnabled 之后,我看到了这个 [FeatureCommentListViewController respondsToSelector:]: message sent to deallocated instance 0x7c1dc30

  1. 在我把项目改成ARC之前没有这个错误,但是我改成ARC之后就出现了这个错误。

  2. 我在 Block 中声明了一个 ViewController 并将其推送到导航控制器中。这个原因会导致它的寿命更短吗?

    UIBlockButton 来自这篇文章

    UIBlockButton *lbGood3 = [[UIBlockButton alloc] initWithFrame:CGRectMake(0, 0, First_Button_Width, [self getGoodRow2Height:productDetail]) ];
    [lbGood3 handleControlEvent:UIControlEventTouchUpInside withBlock:^ { 
    NSLog(@"%@", Label.text); 
    
    ProductDetail *productDetail = [productDetailDict objectForKey:@"product"];
    NSString *dp_id = [NSString stringWithFormat:@"%@-%@",productDetail.url_crc,productDetail.site_id];
    
    
    FeatureCommentListViewController *cmtListController = [[FeatureCommentListViewController alloc] initWithNibName:@"FeatureCommentListViewController" bundle:nil];
    cmtListController.title = Label.text;
    cmtListController.isReviewed=isReviewed;
    cmtListController.productDetail=productDetail;
    cmtListController.dp_id=dp_id;
    cmtListController.feature_name = @"&feature_good_id=2";
    
    [self.navigationController pushViewController:cmtListController animated:YES];
    
    }];
    

我应该将控制器声明为这个 viewController 的成员还是只声明出块?

4

2 回答 2

0

我通过在 viewDidLoad 函数中分配 FeatureCommentListViewController 并在块中使用它来解决这个问题。

于 2012-07-16T10:00:58.347 回答
-2

第一个。我想知道为什么要将视图控制器推送到块中而不是主线程中?对触摸动作做出快速响应不是很重要吗?

第二[self.navigationController pushViewController:cmtListController animated:YES];在你的街区。每当你离开当前navigationControllerself.navigationController代表什么?

第三。如果您声明viewController块外,您可以__block按照 Hermann Klecker 的说明在其前面添加。

于 2012-07-12T15:15:11.360 回答