-4

私は uiscrollview で多くの画像を使用しています。最初に最初の 3 つまたは 4 つの画像をロードしてから、スクロール時に他の画像をロードして解放したいと考えています。

4

1 に答える 1

2

多くのタイプを備えたこのBest CoverFlowを参照してください.....

  1. iCarousel //必要に応じてタイプを変更するだけです。この例では、アニメーション付きの画像のすべてのタイプの表示/出力を取得します
  2. オープンフロー

また、imagePath からの両方の向きでスクロールビューに画像を設定する場合、これは私がそれを使用するために作成する簡単な方法です..必要なコードを変更するだけです..

-(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];
}
于 2012-11-23T05:05:15.623 に答える