Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
armanb21
848 PointsImage in UIImageView is larger than it should be... [Objective-c]
Hello, I have this bug where the UIImageView is small but the image that gets chosen takes up more space than the UIImageView and it makes it practically impossible to use the app. A screenshot of what the bug looks like: http://www.tiikoni.com/tis/view/?id=d0c08e0, and a screenshot of what it should look like is here: http://www.tiikoni.com/tis/view/?id=078556b . The code for images:
- (IBAction)chooseImage:(id)sender {
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc]init];
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
self.imageView.image=image;
[picker dismissViewControllerAnimated:NO completion:nil];
}
UIImage *image = [_imageView image];
NSData *imageData = UIImagePNGRepresentation(image);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:imageData];
[parseMessage setObject:imageFile forKey:@"picture"];
Essentially what I'm trying to do is make that image fit where its supposed to in the UIImageView. Thanks for any help!
Regards, Arman
1 Answer
Stone Preston
42,016 Pointsselect your imageView in your storyboard. in the attributes inspector, you should be able to change its content mode to ScaleAspectFit. that will make scale the image to fit in the imageView
Robin Malhotra
14,883 PointsRobin Malhotra
14,883 PointsYou're looking for UIViewContentModeScaleAspectFit :)
armanb21
848 Pointsarmanb21
848 PointsThank you. -armanb21