Je suis en train de le délégué à un UIAlertView de la manière suivante:délégué UIAlertView écraser l'application
PhotoViewController *controller = [[PhotoViewController alloc] init];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Announcement"
message: @"It turns out that you are playing Addicus!"
delegate: controller
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
Où PhotoViewController est pas le UIviewContorller courant. Les charges d'alerte très bien, mais dès que j'appuie sur le bouton OK, les application se bloque et je reçois cette erreur:
0x3a61a5b0: LDR r3, [r4, # 8] EXC ACCESS BAD
Qu'est-ce que cela signifier?
EDIT:
+ (DejalActivityView *)activityViewForView:(UIView *)addToView withLabel:(NSString *)labelText width:(NSUInteger)aLabelWidth;
{
// Immediately remove any existing activity view:
if (dejalActivityView)
[self removeView];
// Remember the new view (so this is a singleton):
dejalActivityView = [[self alloc] initForView:addToView withLabel:labelText width:aLabelWidth];
if ([labelText isEqualToString:@"Uploading photo (this process might take a while)"]) {
buttonCancel = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[buttonCancel addTarget:dejalActivityView
action:@selector(callCancelAlert:)
forControlEvents:UIControlEventTouchDown];
buttonCancel.frame = CGRectMake(230, 540, 265, 40);
[addToView addSubview:buttonCancel];
[buttonCancel setImage:[UIImage imageNamed:@"socialize-navbar-bg.png"] forState:UIControlStateNormal];
[buttonCancel setTitle:@"Cancel upload" forState:UIControlStateNormal];
}
return dejalActivityView;
}
-(IBAction)callCancelAlert:(id)sender{
PhotoViewController *controller = [[PhotoViewController alloc] init];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Announcement"
message: @"It turns out that you are playing Addicus!"
delegate: controller
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
//[alert release];
}
Est-ce une copie conforme de votre code? Si ce n'est pas le cas, et 'controller' est une propriété' weak', alors elle peut être nulle avant de pouvoir l'utiliser. Dans tous les cas, vérifiez si le contrôleur est non-nul dans le débogueur. Tout le meilleur – virtualnobi
Oui, ceci est le code. Et c'est la seule référence que j'ai à controller, ainsi que #import "PhotoViewController" – Alessandro
Indice: le délégué n'est pas retenu par alertView; –