views:

14

answers:

2

Hi guys,

I've seem to implement all the right code here. Is there something I'm missing in my code?

//
//  ScrollyiPadViewController.m
//  ScrollyiPad
//
//  Created by Sidwyn Koh on 5/19/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "ScrollyiPadViewController.h"

@implementation ScrollyiPadViewController

-(void)viewDidLoad{
    [self.view addSubview:scrollView];
    [scrollView addSubview:imageView];

    UIImage *image = [UIImage imageNamed:@"hardware-01-20100127.jpg"];
    scrollView.contentSize = [image size];
    scrollView.maximumZoomScale = 2.0;
//  scrollView.delegate = self;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    return imageView;
}



/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
A: 

I would

scrollView.contentSize = imageView.frame.size;

rather than

scrollView.contentSize = [image size];
mvds
No such property for imageView :(Also I tried imageView.bounds.size and imageView.frame.size, both didn't work (you couldn't even scroll/zoom)
hakewake
sorry, fixed my answer, should be imageView.frame.size indeed
mvds
A: 

Found it, I forgot to set clipstoBounds=YES

hakewake