我有一個滾動視圖,其中我有一個imageview顯示960x960圖像,但它滾動到接近4倍的東西。我試圖記錄所有可能的視圖的寬度,並聲稱它是960x960(或更小,我認爲我記錄了屏幕寬度一次...?)iPhone SDK滾動查看顯示額外的空間
我需要此圖像以停止滾動在右下角圖像的角落,而不是進入死亡空間。任何幫助將不勝感激。
哎呀,甚至告訴我什麼對象的名稱是比我大scrollView.contentSize會把我在正確的軌道上......
//Test-Image is just a 960 by 960 image that's numbered around the edges 1-10 so you can tell if it's 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's height attribute?...%f", scrollView.contentSize.height);
// Returns 960
NSLog(@"What is in scrollView's 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];
我想看看你是如何構建scrollview的內容。 – ISDi