-3
我在uiscrollview中使用了很多圖像,我想在開始時加載第一個3或4個圖像,然後我想在加載和釋放其他滾動的例子。如何在UIScrollView中加載很多圖像
我在uiscrollview中使用了很多圖像,我想在開始時加載第一個3或4個圖像,然後我想在加載和釋放其他滾動的例子。如何在UIScrollView中加載很多圖像
看到這個最佳的CoverFlow與許多類型.....
而且,如果你想設置的圖像上滾動型從ImagePath的兩個oriantation那麼這就是我創建使用它..只是改變你想要的一些代碼簡單的方法..
-(void) imageFromImagePath : (NSString *) path {
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:path]];
UIImage *img = [UIImage imageWithContentsOfFile:path];
if (img != nil) {
[imageView setBackgroundColor:[UIColor clearColor]];
fullFrame = imageView.frame;
float expWidth, expHeight, orgWidth, orgHeight;
orgWidth = imageView.frame.size.width;
orgHeight = imageView.frame.size.height;
if (orgWidth < orgHeight) {
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
expWidth = 480;
expHeight = (orgHeight * expWidth)/orgWidth;
if (expHeight < 300) {
expHeight = 300;
expWidth = (orgWidth * expHeight)/orgHeight;
}
}
else {
expWidth = 320;
expHeight = (orgHeight * expWidth)/orgWidth;
if (expHeight < 460) {
expHeight = 460;
expWidth = (orgWidth * expHeight)/orgHeight;
}
}
}
else {
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
expHeight = 300;
expWidth = (orgWidth * expHeight)/orgHeight;
if (expWidth < 480) {
expWidth = 480;
expHeight = (orgHeight * expWidth)/orgWidth;
}
}
else {
expHeight = 460;
expWidth = (orgWidth * expHeight)/orgHeight;
if (expWidth < 320) {
expWidth = 320;
expHeight = (orgHeight * expWidth)/orgWidth;
}
}
}
imageView.contentMode = UIViewContentModeScaleToFill;
imageView.image = img;
[scroller addSubview:imageView];
[imageView release];
[scroller bringSubviewToFront:scrollingWheel];
//[self addSubview:scroller];
[imageView setNeedsLayout];
[imageView setNeedsDisplay];
imgWidth = expWidth;
imgHeight = expHeight;
[scrollingWheel stopAnimating];
imageView.frame = CGRectMake(0,0,expWidth,expHeight);
//scroller.frame = CGRectMake(0,0,expWidth,expHeight);
scroller.contentSize = CGSizeMake(expWidth, expHeight);
}
else {
}
//[self performSelector:@selector(hideScrollingWheel) withObject:nil afterDelay:1.0];
}