2013-03-26 6 views
0

Je recherche le meilleur moyen de sélectionner une zone d'image. En fait, je veux charger un certain jpg, et laisser l'utilisateur l'échelle ou le déplacer et obtenir les coordonnées sur l'image d'un carré prédessiné au centre de l'image. Quelle est la meilleure façon de faire cela? Y a-t-il une bibliothèque github que quelqu'un connaît? Merci d'avance byeiOS - Meilleure façon de sélectionner une zone d'une image

+0

Drop-in de remplacement: http://stackoverflow.com/questions/10968845/look-for-a-drop-in-image-redimensionner-crop-view-controller http://stackoverflow.com/questions/11951268/image-crop-in-ios-using-bjimagecropper –

Répondre

4

La meilleure façon est d'utiliser la classe UIImagePickerController.

Vous Invoque cette façon:

-(void) choosePhotoFromLibrary{ 

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
    cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

    // Shows the controls for moving & scaling pictures 
    // To instead hide the controls, use NO. 
    cameraUI.allowsEditing = YES; 
    cameraUI.delegate = self; 

    [self presentViewController:cameraUI animated:YES completion:nil]; 

} 

Et puis obtenir l'image modifiée de cette façon:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 


    UIImage * original = info[@"UIImagePickerControllerEditedImage"]; 
    //Do whatever you want with the image 

    [self dismissViewControllerAnimated:YES completion:nil]; 

} 
Questions connexes