0
//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];

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

4

0 回答 0