0
我想在我的UIImageView上實現滾動和縮放,但它只是垂直滾動。UIScrollView只能垂直滾動
它放大,它垂直滾動,所有東西都連接在InterfaceBuilder中。在InterfaceBuilder中沒有約束。
有人能幫我理解爲什麼嗎?
感謝,
//
// O_GTab2ViewController3.m
// Safety Moment
//
// Created by Fabio Lanza on 3/2/14.
// Copyright (c) 2014 Fabio Lanza. All rights reserved.
//
#import "O_GTab2ViewController3.h"
@interface O_GTab2ViewController3() <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIImage *image;
@end
@implementation O_GTab2ViewController3
@synthesize imageName;
- (void)setScrollView:(UIScrollView *)scrollView {
scrollView.minimumZoomScale = 0.2;
scrollView.maximumZoomScale = 2.0;
scrollView.contentSize = self.imageView.image.size;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.imageView;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.image = [UIImage imageNamed:imageName];
self.imageView.image = self.image;
self.imageView.contentMode = UIViewContentModeTopLeft;
[self.imageView sizeToFit];
self.scrollView.frame = CGRectMake(0, 64, 320, 455);
self.scrollView.contentSize = self.imageView.image.size;
self.scrollView.delegate = self;
// [self.view addSubview:self.scrollView];
[self.scrollView addSubview:self.imageView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end