I narrowed down the ugly bug, but since it seems to be something internal to nib / Interface Builder, I don’t understand what to do next.
I have a UIView created in IB that functions as a custom dialog. It shows a message and two buttons. (Continue or Cancel.) Both buttons have a background image set in Interface Builder.
Something is wrong with how the background image for the cancel button is processed. With NSZombieEnabled, I run the program. Most often, the method below logs this:
-[ModalDialog showInView:title:message:cancelText:proceedText:]
dialogProceedButton <UIButton: 0x7031f10; frame = (286 192; 90 31)
dialogProceedButtonBackground <UIImage: 0x3b36120>
dialogCancelButton <UIButton: 0x3b39cd0; frame = (104 192; 90 31)
dialogCancelButtonBackground <UIImage: 0x3b3a920>
This is completely normal. However, sometimes he does this (I can make it repeat somewhat reliably if I "rush" with the user interface by quickly pressing some interface buttons):
-[ModalDialog showInView:title:message:cancelText:proceedText:]
dialogProceedButton <UIButton: 0x7031f10; frame = (286 192; 90 31)
dialogProceedButtonBackground <UIImage: 0x3b36120>
dialogCancelButton <UIButton: 0x3b39cd0; frame = (104 192; 90 31)
*** -[UIImage retain]: message sent to deallocated instance 0x3b3a920
, NSZombieEnabled , "" , . ( , ... Interface Builder. IBOutlets , .)
, , ?
EDIT:
, , KindOfClass:
-[UIImage isKindOfClass:]: message sent to deallocated instance 0x1661f0
*** NSInvocation: warning: object 0x7e0d0b0 of class '_NSZombie_UIImage' does not implement methodSignatureForSelector: -- trouble ahead
*** NSInvocation: warning: object 0x7e0d0b0 of class '_NSZombie_UIImage' does not implement doesNotRecognizeSelector: -- abort
UIViews showInView:
- (void)showInView:superView
title:(NSString*)title
message:(NSString*)message
cancelText:(NSString*)cancelText
proceedText:(NSString*)proceedText {
NSLog(@"%s",__PRETTY_FUNCTION__);
NSLog(@"dialogProceedButton %@", dialogProceedButton);
NSLog(@"dialogProceedButtonBackground %@", dialogProceedButton.currentBackgroundImage);
NSLog(@"dialogCancelButton %@", dialogCancelButton);
NSLog(@"dialogCancelButtonBackground %@", dialogCancelButton.currentBackgroundImage);
CGRect rect;
dialogTitle.text = title;
dialogMessage.text = message;
[dialogProceedButton setTitle:proceedText forState:UIControlStateNormal];
if (cancelText == @"") {
dialogCancelButton.hidden = YES;
rect = [dialogProceedButton frame];
rect.origin.x = 195;
[dialogProceedButton setFrame:rect];
} else {
[dialogCancelButton setTitle:cancelText forState:UIControlStateNormal];
dialogCancelButton.hidden = NO;
rect = [dialogProceedButton frame];
rect.origin.x = 286;
[dialogProceedButton setFrame:rect];
}
[UIView beginAnimations:@"modalAppears" context:nil];
[UIView setAnimationDuration:0.5];
[superView addSubview:self];
self.alpha = 1.0;
[UIView commitAnimations];
}
!