【发布时间】:2013-06-23 14:43:52
【问题描述】:
我正在构建一个相机应用程序,但我无法对图像进行缩放。老实说,我不知道从哪里开始,我敢肯定这是我错过的一些愚蠢的错误。该应用程序将 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;
}
【问题讨论】:
-
最大和最小缩放比例设置为多少?
-
0.01f/6.0f,我很抱歉
-
你确认你的出口
chosenImageView不是零? -
选中/在滚动视图和图像视图上将
userInteractionEnabled设置为 YES(可能图像视图是问题,因为它默认设置为 NO) -
我打开了它们,但它仍然不起作用。我还尝试在 UIImageView 上将多点触控设置为启用。
标签: objective-c uiview uiscrollview uiscrollviewdelegate