CoolButtons icon indicating copy to clipboard operation
CoolButtons copied to clipboard

EXC_BAD_ACCESS in layoutSubviews

Open jonoogle opened this issue 13 years ago • 3 comments

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

jonoogle avatar Nov 22 '11 18:11 jonoogle

I have the same problem. When I comment the line away the button appears to look fine to me...

Hackmodford avatar Nov 27 '11 04:11 Hackmodford

I have the same Problem. Any ideas Jess?

DoctorG avatar Feb 18 '12 01:02 DoctorG

I just uncommented the line and for some reason I no longer have the issue.

Hackmodford avatar May 02 '12 15:05 Hackmodford