Pregunta

I'm building a camera application, and I can't get the zooming on the image to work. I honestly don't know where to go from here, I'm sure it's some dumb mistake that I'm missing though. The app sets the chosenImageView to the workingImage (picture from the camera). When I try to zoom, nothing happens.

ViewController.h

@interface ViewController : UIViewController <UIActionSheetDelegate, UIImagePickerControllerDelegate, UIScrollViewDelegate>

@property (strong, nonatomic) UIImage *workingImage;
@property (weak, nonatomic) IBOutlet UIImageView *chosenImageView;
@property (weak, nonatomic) IBOutlet UIScrollView *imageScroller;

-(IBAction)cameraButtonPressed;

@end

ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.imageScroller.minimumZoomScale = 0.01f;
    self.imageScroller.maximumZoomScale = 6.0f;
    self.imageScroller.contentSize = self.imageScroller.frame.size;
    self.imageScroller.scrollEnabled = YES;

    self.navigationController.navigationBar.tintColor = [UIColor blackColor];

}

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.chosenImageView;
}

Hierarchy of my IB Items

Useless picture of the interface builder section with the UIScrollView/UIImageView

¿Fue útil?

Solución

Here was the problem. You have to control+drag from the UIScrollView to the View Controller to set the delegate.

Setting the delegate in interface builder

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top