我正在构建一个相机应用程序,但无法放大图像。老实说,我不知道从哪里开始,我敢肯定这是我错过的一些愚蠢的错误。该应用程序将 selectedImageView 设置为 workingImage(来自相机的图片)。当我尝试缩放时,没有任何反应。
视图控制器.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
视图控制器.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;
}