UIButton, utworzony przez Interface Builder, ulega awarii

Zawęziłem brzydki błąd, ale ponieważ wydaje się, że jest to coś wewnętrznego w narzędziu do budowania interfejsów, nie rozumiem, co robić dalej.

Mam UIView utworzony w IB, który działa jako niestandardowe okno dialogowe. Pokazuje komunikat i dwa przyciski. (Kontynuuj lub Anuluj.) Oba przyciski mają ustawiony obraz tła w Konstruktorze interfejsu.

Coś jest nie tak z sposobem obsługi obrazu tła przycisku Anuluj. Z NSZombieEnabled uruchomiłem program. Najczęściej poniższa metoda rejestruje to:

-[ModalDialog showInView:title:message:cancelText:proceedText:]
dialogProceedButton <UIButton: 0x7031f10; frame = (286 192; 90 31) // (etc.)
dialogProceedButtonBackground <UIImage: 0x3b36120>
dialogCancelButton <UIButton: 0x3b39cd0; frame = (104 192; 90 31) // (etc.)
dialogCancelButtonBackground <UIImage: 0x3b3a920>

To całkowicie normalne. Czasami jednak to robi (mogę to pewnie powtórzyć, jeśli „spieszę” interfejs użytkownika szybko stukając w niektóre przyciski interfejsu):

-[ModalDialog showInView:title:message:cancelText:proceedText:]
dialogProceedButton <UIButton: 0x7031f10; frame = (286 192; 90 31) // (etc.)
dialogProceedButtonBackground <UIImage: 0x3b36120>
dialogCancelButton <UIButton: 0x3b39cd0; frame = (104 192; 90 31) // (etc.)
*** -[UIImage retain]: message sent to deallocated instance 0x3b3a920

Jak widać, NSZombieEnabled odkrył, że obraz tła przycisku Anuluj został zwolniony, ale wysyłany jest komunikat zatrzymania. (Ale nie przeze mnie ... ten obraz jesttylko używane dla tego jednego przycisku, itylko dostępne w Konstruktorze interfejsów. Nie mam żadnych IBOutletów ani żadnych zmiennych powiązanych z tym obrazem.)

Więc co teraz?

EDYTOWAĆ:

Czasami nie jest to wiadomość zatrzymana, która zostaje złapana jako zombie, czasami jest to KindOfClass:

//(the object address is always dialogCancelButton.currentBackgroundImage)
-[UIImage isKindOfClass:]: message sent to deallocated instance 0x1661f0
//occasionally, these come along, too:
*** 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

To jest moja niestandardowa metoda „showInView” UIViews:

- (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 == @"") { // SINGLE BUTTON DIALOG
  dialogCancelButton.hidden = YES;
  rect = [dialogProceedButton frame];
  rect.origin.x = 195; //center the button 
  [dialogProceedButton setFrame:rect];
} else {
  [dialogCancelButton setTitle:cancelText forState:UIControlStateNormal];
  dialogCancelButton.hidden = NO;
  rect = [dialogProceedButton frame];
  rect.origin.x = 286; //button on right of dialog box 
  [dialogProceedButton setFrame:rect];
}

[UIView beginAnimations:@"modalAppears" context:nil];
[UIView setAnimationDuration:0.5];
[superView addSubview:self];
self.alpha = 1.0;
[UIView commitAnimations];
}

Dzięki!

questionAnswers(2)

yourAnswerToTheQuestion