In IB it would be all options activated scrollView. AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; scrollView. ContentSize = content.frame.
Size; // or bounds, try both what do you mean with scrollableArea? Your minZoomScale is set to 1.0 thats fine for portrait mode but not for landscape. Because in landscape your height is smaller than in portrait you need to have a value smaller than 1.0 For me I use this implementation and call it every time, the frame of the scrollView did change: (void)setMaxMinZoomScalesForCurrentBounds { CGSize boundsSize = self.bounds.
Size; // self is a UIScrollView here CGSize contentSize = content.bounds. Size; CGFloat xScale = boundsSize. Width / contentSize.
Width; CGFloat yScale = boundsSize. Height / contentSize. Height; CGFloat minScale = MIN(xScale, yScale); if (self.ZoomScale.
In IB it would be all options activated scrollView. AutoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; scrollView. ContentSize = content.frame.
Size; // or bounds, try both what do you mean with scrollableArea? Your minZoomScale is set to 1.0 thats fine for portrait mode but not for landscape. Because in landscape your height is smaller than in portrait you need to have a value smaller than 1.0.
For me I use this implementation and call it every time, the frame of the scrollView did change: - (void)setMaxMinZoomScalesForCurrentBounds { CGSize boundsSize = self.bounds. Size; // self is a UIScrollView here CGSize contentSize = content.bounds. Size; CGFloat xScale = boundsSize.
Width / contentSize. Width; CGFloat yScale = boundsSize. Height / contentSize.
Height; CGFloat minScale = MIN(xScale, yScale); if (self. ZoomScale MinimumZoomScale = minScale; //self setZoomScale:minScale animated:YES; } - (void)setFrame:(CGRect)rect { // again, this class is a UIScrollView super setFrame:rect; self setMaxMinZoomScalesForCurrentBounds; }.
Thanks, looks promising. So you have subclassed UIScrollView it looks like? – morningstar Oct 13 at 17:05 scrollableArea is just a plain UIView.It does nothing but contain other UIViews.
It's my viewForZoomingInScrollView. I need it between scrollView and content because of the funny sizes I've set to get things to approximately work. I also need it because occasionally there is an additional view inside it besides content.
– morningstar Oct 13 at 17:08 I thought about having a min zoom less than 1.0, but there is really no reason to see the full height of the content in landscape mode and a lot of black area to the sides. The interface would become too small to be useable. If you want to see the full height, use portrait mode.
I actually considered setting min zoom to more like 1.5 for landscape so the content always at least fills the screen. – morningstar Oct 13 at 17:11 then the contentSize should be the frame of your scrollableArea. Yep I have subclassed it because I have some quartz rendering a pdf.
– iPortable Oct 13 at 17:14 Didn't work. Same results as the other answer. – morningstar Oct 137 at 17:07.
I don't think I understood the entire problem from your post, but here's an answer for what I did understand. As far as I know (and worked with UIScrollView), the content inside a UIScrollView is not automatically autoresized along with the UIScrollView. Consider the UIScrollView as a window/portal to another universe where your content is.
When autoresizing the UIScrollView, you are only changing the shape/size of the viewing window... not the size of the content in the other universe. However, if needed you can intercept the rotation event and manually change your content too (with animation so that it looks good). For a correct autoresize, you should change the contentSize for the scrollView (so that it knows the size of your universe) but also change the size of UIView.
I think this is why you were able to scroll and get that black content. Maybe you just updated the contentSize, but now the actuall content views. Personally, I haven't encountered any case that required to resize the content along with the UIScrollView, but I hope this will get you started in the right direction.
– morningstar Oct 7 at 13:56 I tried that, and set all my sizes back to normal sizes, and removed my custom code that was doing things like setting content insets. I had a few problems.1 When I rotate to landscape, my content is nicely centered, but I cannot scroll all the way to the top of my content.2 If I zoom, then rotate to landscape, I can reach all of the content, but if I zoom out the content is not centered; it is all the way on the left of the screen.3 If I zoom while in landscape, then return to portrait, I cannot reach all the content. With multiple steps, I even got the content all the way off the screen.
– morningstar Oct 7 at 14:56.
If I understand correctly is that you want a scrollview with an image on it. It needs to be fullscreen to start with and you need to be able to zoom in. On top of that you want it to be able to rotate according to orientation.
Well I've been prototyping with this in the past and if all of the above is correct the following code should work for you. I left a bit of a white area for the bars/custombars. - (void)viewDidLoad { super viewDidLoad; //first inits and allocs scrollView2 = UIScrollView alloc initWithFrame:self.view.
Frame; imageView = UIImageView alloc initWithImage:UIImage imageNamed:@"someImageName"; scrollView2 addSubview:imageView; self drawContent; //refreshing the content self. View addSubview:scrollView2; } -(void)drawContent { //this refreshes the screen to the right sizes and zoomscales. ScrollView2 setBackgroundColor:UIColor blackColor; scrollView2 setCanCancelContentTouches:NO; scrollView2.
ClipsToBounds = YES; scrollView2 setDelegate:self; scrollView2. IndicatorStyle = UIScrollViewIndicatorStyleWhite; scrollView2 setContentSize:CGSizeMake(imageView.frame.size. Width, imageView.frame.size.
Height); scrollView2 setScrollEnabled:YES; float minZoomScale; float zoomHeight = imageView.frame.size. Height / scrollView2.frame.size. Height; float zoomWidth = imageView.frame.size.
Width / scrollView2.frame.size. Width; if(zoomWidth > zoomHeight) { minZoomScale = 1.0 / zoomWidth; } else { minZoomScale = 1.0 / zoomHeight; } scrollView2 setMinimumZoomScale:minZoomScale; scrollView2 setMaximumZoomScale:7.5; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { // Portrait //the 88pxls is the white area that is left for the navbar etc. Self. ScrollView2.
Frame = CGRectMake(0, 88, UIScreen mainScreen.bounds.size. Width, self.view.frame.size. Height - 88); self drawContent; } else { // Landscape //the 88pxls is the white area that is left for the navbar etc. Self.
ScrollView2. Frame = CGRectMake(0, 88, UIScreen mainScreen.bounds.size. Height, self.view.frame.size.
Width); self drawContent; } return YES; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self. ImageView; } I hope this will fix your troubles. If not leave a comment.
When you want to put a content (a UIView instance, let's call it theViewInstance ) in a UIScrollView and then scroll / zoom on theViewInstance , the way to do it is : theViewInstance should be added as the subview of the UIScrollView set a delegate to the UIScrollView instance and implement the selector to return the view that should be used for zooming / scrolling: -(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView { return theViewInstance; } Set the contentSize of the UIScrollView to the frame of the theViewInstance by default: scrollView. ContentSize=theViewInstance.frame. Size; (Additionally, the accepted zoom levels can be set in the UIScrollView :) scrollView.
MinimumZoomScale=1.0; scrollView. MaximumZoomScale=3.0; This is the way a pinch to zoom is achieved on a UIImage : a UIImageView is added to a UIScrollView and in the UIScrollViewDelegate implementation, the UIImageView is returned (as described here for instance). For the rotation support, this is done in the UIViewController whose UIView contains the UIScrollView we just talked about.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.