zwaldowski/BlocksKit — Issue #67: UIButton - crash on didReceiveMemoryWarning
Author: edowling
Created: 2012-02-09 11:54:21+00:00
State: open

Adding an event handler to a UIButton that pushes a view controller onto the current navigation controller causes a crashes in [super didReceiveMemoryWarning];

The offending code is:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(194, 4, 126, 70)];
[button setBackgroundColor:[UIColor clearColor]];
[button addEventHandler:(BKSenderBlock)^ {

AViewController *viewController = [[AViewController alloc] initWithNibName:@"AViewController" bundle:nil]
[self.navigationController pushViewController:viewController animated:YES];

} forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

Countless hours of debugging and on-device and simulator memory warnings have pinpointed the [button addEventHandler] to be the culprit.

Running the block in the main thread using GCD does not solve the crash.