ARC的EXC_BAD_ACCESS

时间:2012-04-19 17:15:45

标签: ios automatic-ref-counting exc-bad-access

//tool bar
__strong UIToolbar *tBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,
                                                              self.view.frameHeight-49.0f-44.0f,
                                                              [UIScreen mainScreen].bounds.size.width, 49.0f)];
UITextField* cText = [[UITextField alloc] initWithFrame:CGRectMake(8, 12, 150, 28)];
self.codeText  = cText;
_codeText.backgroundColor = [UIColor whiteColor];
_codeText.placeholder = @"Input code";
[tBar addSubview:_codeText];

UIButton *obtn = [[UIButton alloc] initWithFrame:CGRectMake(180, 12, 60, 28)];
self.okBtn = obtn;
[self.okBtn setTitle:@"OK" forState:UIControlStateNormal];
self.okBtn.titleLabel.textColor = [UIColor whiteColor];
self.okBtn.backgroundColor = [UIColor blueColor];
[self.okBtn addTarget:self action:@selector(confirm) forControlEvents:UIControlEventTouchUpInside];
[tBar addSubview:self.okBtn];

self.cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(250, 12, 60, 28)];
[_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
_cancelBtn.titleLabel.textColor = [UIColor whiteColor];
_cancelBtn.backgroundColor = [UIColor blueColor];
[_cancelBtn addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
[tBar addSubview:_cancelBtn];

[self.view addSubview:tBar];

这个代码在我的项目中的控制器中的loadView函数中启用了ARC;但是当我触摸两个按钮中的任何一个时,它总是崩溃“EXC_BAD_ACCESS”。我已经使用zombie来调试,但是有没问题。

0 个答案:

没有答案