我有一个错误警报视图,当我单击“确定”时会崩溃
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"OK" forState:UIControlStateNormal];
[button setFrame:CGRectMake(10, 80, 266, 43)];
[button addTarget:self action:@selector(dismissError:) forControlEvents:UIControlEventTouchUpInside];
[alertView addSubview:button]; //This is a subview of
//...other stylings for the custom error alert view
errorWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
errorWindow.windowLevel = UIWindowLevelStatusBar;
errorWindow.hidden = NO;
[errorWindow addSubview:alertView];
[errorWindow makeKeyAndVisible];
}
此 alertView 位于自定义 ErrorAlert:UIView 中。
此警报显示正常。
但是,当单击“确定”按钮时,应用程序崩溃,它从未到达 - (void)dismissError:(id)sender;
我是否在错误的位置添加了按钮?(它给出了通用的 int retVal=......EXC_BAD_ACCESS)