AutoResizing Image no imageView
i am using AFOpenFlow in my app, but now the Problem is, the pictures I use 开发者_StackOverfloware not the same size because they are from the web! And how can i autoResizing the image at the view of the iPhone??? Here is my code from this method:
- (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];
}
Thank you beforehand Marco
scale your image before set to open flow change your code in the loop as below:
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);
精彩评论