I get image for imageView using UIImagePickerController
like this
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *originalImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
CGSize destinationSize1 = CGSizeMake(200, 200);
UIGraphicsBeginImageContext(destinationSize1);
[originalImage drawInRect:CGRectMake(0,0,destinationSize1.width,destinationSize1.height)];
UIImage *newImage1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
firstimage1.image = newImage1;
[picker dismissViewControllerAnimated:YES completion:nil];
NSLog(@"image width is %f",firstimage1.image.size.width);
NSLog(@"image height is %f",firstimage1.image.size.height);
if (firstimage1.image.size.width==200 && firstimage1.image.size.height==200) {
UIAlertView *alertcrp=[[UIAlertView alloc]initWithTitle:@"message!" message:@"you want to crop this image" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[alertcrp addButtonWithTitle:@"Crop "];
[alertcrp show];
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Button Index =%ld",(long)buttonIndex);
if (buttonIndex == 0)
{
NSLog(@"You have clicked Cancel");
}
else if(buttonIndex == 1)
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.allowsEditing = YES; // this will allow you to crop the image first
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
}
We resize image to 200*200.Now What i need is When User is upload image .If image is upload success and then open alertView "if you want to Crop the image". Once click the crop button i need to Open Rectangle crop View .
Please give me any idea about my problem.Thanks in Advanced.