I've a UIScrollView - 590 x 650 I've 2 UIImages in the scroll view with dimensions : 620 x 450 So, I set the contentsize and properties thus :
self.scroller.minimumZoomScale=0.5;
self.scroller.maximumZoomScale=6.0;
self.scroller.contentSize=CGSizeMake(1350, 950);// EDIT : 1350 because 620 + 620
//950 because 450 + 450 and 50 extra
self.scroller.contentInset=UIEdgeInsetsMake(64.0,0.0,44.0,0.0);
self.scroller.scrollIndicatorInsets=UIEdgeInsetsMake(64.0,0.0,44.0,0.0);
self.scroller.delegate=self;
But when I try to run and scroll, only half/partial of the second image is displayed and the scroll bounces back, even when I pull the scroll all the way to display the end of the second image.
what am i doing wrong here??
Is my content size setting/assumption correct??
If this question is already answered please point me to it, as I couldn't find the correct explanation.
EDITS : *.h file
@interface ViewController : UIViewController<UIScrollViewDelegate>
{
UIScrollView *scroller;
UIImageView *varImage1;
UILabel *lblStyle;
BOOL isAlpha;
UITextView *textView;
}
@property (retain, nonatomic) IBOutlet UIScrollView *scroller;
@property (retain, nonatomic) IBOutlet UIImageView *varImage1;
@property (retain, nonatomic) IBOutlet UILabel *lblStyle;
- (IBAction)notesClick:(id)sender;
@property (retain, nonatomic) IBOutlet UIButton *notesClick;
@property (retain, nonatomic) IBOutlet UITextView *textView;
@end
*.m file
// calculate minimum scale to perfectly fit image width, and begin at that scale
float minimumScale = [scroller frame].size.width / [varImage1 frame].size.width;
[scroller setMinimumZoomScale:minimumScale];
[scroller setZoomScale:minimumScale];
scroller.contentSize= CGSizeMake(960,1170);
scroller.delegate=self;
Image size is 1170x960 UIImage view size is : 1170x960 (width x height) picture set form IB and property set to scale to fit.
scroll view size is 590 x 650 (width x height)
object hierarchy :
Initial view on load : *NOTE : Even thought image is partially displayed, I can't scroll to the right and see the rest of the image.
After i zoom out the image, I can scroll even if the image is only partially being displayed