jessmartin/CoolButtons — Issue #11: EXC_BAD_ACCESS in layoutSubviews
Author: jonoogle
Created: 2011-11-22 18:06:07+00:00
State: open

The line crashes on the fourth invocation of layoutSubviews, in particular on this line

[_innerView setBackgroundColor:[self buttonColor]];

#0	0x00003c66 in -[CoolButton layoutSubviews] at /Users/jon/projects/interval6i/CoolButton/CoolButton.m:166
#1	0x00512322 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()

If I comment out the line, it works, but I think the button is missing perhaps a shadow, but I'm not sure.

I'm using the newest SDK (4.2).
The button is included as the titleView on the navigationController toolbar. The viewController is being presented modally.
Here's the code for creating the button. Perhaps I've done something wrong?

UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 29)];
CoolButton *todayButton;
todayButton = [[CoolButton alloc] initWithFrame:CGRectZero];
[todayButton setButtonColor:[UIColor colorWithRed:190./255.0 green:0./255.0 blue:0/255.0 alpha:1.0]];
todayButton.frame = CGRectMake(0, 2, 100, 29);
[todayButton setTitle:NSLocalizedString(@"Today", @"") forState:UIControlStateNormal];
todayButton.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
[todayButton addTarget:self action:@selector(today) forControlEvents:UIControlEventTouchDown];
[titleView addSubview:todayButton];
[todayButton release];
self.navigationItem.titleView = titleView;
[titleView release];