0
我有一个崩溃当我点击“OK”UIButton的点击崩溃的应用程序
- (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)
你尝试打开NSZombies检查一下释放实例收到消息? –
是的。这解决了这个问题。点击之前,autorelease打勾。 – Edison