0

アプリでAFOpenFlowを使用していますが、問題は、使用する写真がWebからのものであるため、同じサイズではないことです! そして、どうすればiPhoneのビューで画像を自動サイズ変更できますか??? このメソッドからの私のコードは次のとおりです。

- (void)viewDidLoad {
    [super viewDidLoad];

    // loading images into the queue

    loadImagesOperationQueue = [[NSOperationQueue alloc] init];


    NSString *imageName;
    for (int i=0; i < 10; i++) {
        imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
        [(AFOpenFlowView *)self.view setImage:[UIImage imageNamed:imageName] forIndex:i];
        [imageName release];
        NSLog(@"%d is the index",i);

    }
    [(AFOpenFlowView *)self.view setNumberOfImages:10];


}

事前にありがとうマルコ

4

1 に答える 1

1

以下のようにループ内のコードを変更してフローを開くように設定する前に、画像をスケーリングします。

imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
UIImage *oriImage = [UIImage imageNamed:imageName];
[imageName release];

UIImage *requiredImage = [UIImage imageWithCGImage:[oriImage CGImage] scale:768/520.0 orientation:UIImageOrientationUp];

[(AFOpenFlowView *)self.view setImage:requiredImage forIndex:i];
NSLog(@"%d is the index",i);
于 2011-10-19T01:02:13.437 に答える