0

UIScrollView に画像がありますが、画像が正しく表示されません。問題は、画像が同じサイズではないことです。同じサイズと高さのすべての画像が必要です。

for (UIView *v in [_scrollView subviews]) {
    [v removeFromSuperview];
}

//CGRect workingFrame = _scrollView.frame;
CGRect workingFrame = CGRectMake(0, 0, 200, 134);
workingFrame.origin.x =0;

NSMutableArray *images = [NSMutableArray arrayWithCapacity:[info count]];


for(NSDictionary *dict in info) {

    UIImage *image = [dict objectForKey:UIImagePickerControllerOriginalImage];
    [images addObject:image];

    UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
    [imageview setContentMode:UIViewContentModeScaleAspectFit];
    imageview.frame = workingFrame;

    [_scrollView addSubview:imageview];
    [imageview release];

    workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}

self.chosenImages = images;
NSLog(@"values=%@",_chosenImages);

[_scrollView setPagingEnabled:YES];
[_scrollView setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];
4

1 に答える 1