我已经尝试过为此寻找答案,但我不知道该搜索什么,而且我已经结束了。我有一个UIScrollView,当缩放时,它会完全翻转,图像会出现故障,然后完全消失。它有时会设法暂时搞砸其他组件,这些组件甚至不是UIScrollView的一部分,在这些组件中正在进行缩放。我道歉,我不能更专业。我甚至不知道要查看我的代码的哪一部分。
我制作了一个视频,因为我没有技术术语来描述这里发生的事情。任何帮助将不胜感激。
https://www.youtube.com/watch?v=SvhqHI-3_g8
红色是我目前的UIScrollView背景。别介意了。
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 = 1.00f;
self.imageScroller.maximumZoomScale = 15.0f;
self.imageScroller.contentSize = self.imageScroller.frame.size;
self.imageScroller.scrollEnabled = YES;
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.chosenImageView;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *chosenImage = [info objectForKey:UIImagePickerControllerOriginalImage];
[self.chosenImageView setImage:chosenImage];
[self.imageScroller setContentSize:chosenImage.size];
[self dismissViewControllerAnimated:YES completion:nil];
}
答案 0 :(得分:1)
看看这篇文章是否有帮助。似乎缺少ScrollViewDidZoom方法可能是维持缩放视图的关键。 http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content