构建相机应用程序... UIScrollView不会缩放

时间:2013-06-23 14:43:53

标签: objective-c uiview uiscrollview uiscrollviewdelegate

我正在构建一个相机应用程序,我无法使图像缩放工作。老实说,我不知道从哪里开始,我确定这是一个我不知道的愚蠢错误。该应用程序将selectedImageView设置为workingImage(来自相机的图片)。当我尝试缩放时,没有任何反应。

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

1 个答案:

答案 0 :(得分:0)

这是问题所在。您必须控制+从UIScrollView拖动到View Controller以设置委托。

Setting the delegate in interface builder