Seeing SIGABRT on [UIButton buttonWithType: initWithFrame:] in iOS 4.0?
Sunday, July 25, 2010 at 4:54PM It's likely because you shouldn't have been calling it the first place.
For whatever reason (and I honestly don't know why), we were using the following call in an originally iPhone 3.x compiled app:
UIButton *btn=[[UIButton buttonWithType:UIButtonTypeRoundedRect] initWithFrame:CGRectMake(x, y, w, h)];
Turns out this worked in 3.x (and still works on apps compiled against a 3.x base SDK), but when compiled against a 4.x base SDK causes a [NSException raise:format:arguments:] exception on init-ing the button.
Anyway, fix is simple enough - init the UIButton as it was meant to be (SDK class refererence):
UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setFrame:CGRectMake(x, y, w, h)];
Order restored, compiling fine against iOS 4.0 (well, 4.0.1 now) base SDK. No idea why the combined init worked before, but simple enough to resolve.







