2013-03-26 67 views
0

我在尋找選擇圖像區域的最佳方式。 實際上,我想加載一些jpg,並讓用戶縮放或移動它,並獲取圖像中心的預繪製正方形圖像上的座標。 這樣做的最好方法是什麼?有人知道的github庫嗎? 在此先感謝 再見iOS - 選擇圖像區域的最佳方式

+0

直接替代: http://stackoverflow.com/questions/10968845 /尋找一個在圖像調整大小作物視圖控制器 http://stackoverflow.com/questions/11951268/image-crop-in-ios-using-bjimagecropper – 2013-03-26 18:49:32

回答

4

最好的辦法是使用UIImagePickerController類。

你invoque這樣說:

-(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]; 

} 

,然後得到編輯的圖像是這樣的:

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


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

    [self dismissViewControllerAnimated:YES completion:nil]; 

}