View scrolling iPhone SDK showing extra space

I have a scroll view in which I have an image displaying a 960x960 image, but it scrolls to about 4x. I tried to record the width of all possible views, and everything claims to be 960x960 (or less, I think I registered the screen width once ...?)

I need this image to stop scrolling in the lower right corner of the image, and not enter the dead space. Any help would be greatly appreciated.

Damn, even telling me which object name is bigger than my scrollView.contentSize will put me on the right path ...

//Test-Image is just a 960 by 960 image that numbered around the edges 1-10 so you can tell if it being moved
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Test-Image.png"]];
self.imageView = tempImageView;
[tempImageView release];

scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);

//Tested with this, results the same.
//[scrollView setContentSize:CGSizeMake(960, 960)];

NSLog(@"What is my scrollView height attribute?...%f", scrollView.contentSize.height);
// Returns 960
NSLog(@"What is in scrollView width attribute?...%f", scrollView.contentSize.width);
// Returns 960

scrollView.contentOffset = CGPointMake(480, 480);

scrollView.maximumZoomScale = 8.0;
scrollView.minimumZoomScale = 0.25;
// Commenting clipsToBounds out doesn't seem to have any effect
scrollView.clipsToBounds = YES;
scrollView.delegate = self;

[scrollView addSubview:imageView];
+3
source share
1 answer

, .

  • . [scrollView addSubview: self.imageView]; [... addSubview: imageView];

  • . ImageView.
    [scrollView setContentSize: CGSizeMake (imageView.frame.size.width, imageView.frame.size.height)];

  • . scrollview (oIWScroll.delegate = self;)?

  • Clipping

    . .

  • ScrollView Frame. , , [UIScreen mainScreen].applicationFrame.

  • . , , , , , UIView, . .
    contentMode = UIViewContentModeTop.

, .

+1

Source: https://habr.com/ru/post/1734464/


All Articles