Code ci-dessous.UIImagePickerController ne fait rien lorsque vous utilisez l'appareil photo après avoir frappé le bouton "Utiliser"
Lorsque j'appuie sur le bouton "Utiliser" après avoir pris une photo ... l'application ne répond plus. Des idées de ce que je fais mal? La méthode "addPlayer:" est appelée lorsqu'un bouton est appuyé sur la vue de UIViewController.
Merci
- (IBAction) addPlayers: (id)sender{
// Show ImagePicker
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
// If camera is available use it and display custom overlay view so that user can add as many pics
// as they want without having to go back to parent view
if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Grab original image
UIImage *photo = [info objectForKey:UIImagePickerControllerOriginalImage];
// Resize photo first to reduce memory consumption
[self.photos addObject:[photo scaleToSize:CGSizeMake(200.0f, 300.0f)]];
// Enable *PLAY* button if photos > 1
if([self.photos count] > 1) btnStartGame.enabled = YES;
// Update player count label
lblPlayerCount.text = [NSString stringWithFormat:@"%d", [self.photos count]];
// Dismiss picker if not using camera
picker dismissModalViewControllerAnimated:YES];
}
quelle ligne-t-il à arrêter? – willcodejavaforfood
Quelle méthode votre bouton "Utiliser" appelle-t-il? – schaechtele
Le bouton "Utiliser" (à partir des commandes intégrées de la caméra) appelle la méthode UIImagePickerControllerDelegate ci-dessus. J'ai réussi à obtenir ce travail mais seulement après avoir déplacé le "[picker dismissModalViewControllerAnimated: YES];" ligne vers le haut de la même méthode. Cependant, semble encore un peu léthargique. – wgpubs