0

I am newbie to iOS programming.

I have a few simple questions.

  1. After picking image from gallery or taking a picture from camera, I want to select

rectangle area like android

UIImagePickerController * picker =[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing=YES;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;

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

When I use this code, I can't resize my area as you see below

enter image description here.

  1. It is related to first question.

As you see my image is resized and changed to different ratio.

But I want image is fixed with original ratio.

enter image description here

  1. Anyone knows how to use camera in iOS simulator?
Kevin
  • 16,696
  • 7
  • 51
  • 68
  • Are you using Storyboards or code only? If you are using the storyboard to present the image, the image will be dependent on the size of the UIImageView frame you have set. – App Dev Guy Dec 08 '14 at 01:42

1 Answers1

0

Question 3: You cannot use the camera function in simulator. That is one of the limitations. See this document from Apple Developer page: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/TestingontheiOSSimulator.html

Question 2: below

This is answer is from this link: How to make UIImageView automatically resize to the size of the image loaded

UIImage img = [UIImage imageNamed:@"myImage.jpg"];
[imageView setImage:img];
imageView.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y,
                         img.size.width, img.size.height);

"This will however not change the layout of view it is contained within, you can make it change the sizes of the other views automatically under iOS 6 using Layout Constraints. If you are an Apple Developer you can watch the WWDC instruction videos, they explain how that system works quite well."

It's the best answer I have as it is the way I use setting image sizes in a view.

Community
  • 1
  • 1
App Dev Guy
  • 5,396
  • 4
  • 31
  • 54