我使用collectionview
顯示從服務器獲取的產品。但圖像不適合collectionview
單元格。我想知道是否有修復它的方法?圖像適合UICollectionView單元格
NSURL *url = [NSURL URLWithString:@"http://www.myURL/productAll.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
NSError *myError = nil;
id res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&myError];
items = [[NSMutableArray alloc] init];
for (int i=0; i<[res count]; i++) {
NSString *arrayResult = [[res objectAtIndex:i]objectForKey:@"image"];
NSData *data = [[NSData alloc] initWithBase64EncodedString:arrayResult options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *captcha_image = [[UIImage alloc] initWithData:data];
[items addObject:captcha_image];
}
[collectionView reloadData];
}];
這裏是collectionView
電池設計,imageView
尺寸與collectionView
細胞匹配。
下面是用戶看到的是:
下面是ImageView的
的額外信息cellCollectionView
放大圖像您是否嘗試過釘扎的UIImageView到上海華邊界和將contentMode設置爲aspectToFill? –
我添加了更多設置信息(屏幕截圖) – hotspring
,嘗試使用自動佈局約束。讓所有四個方面的形象,甚至你可以嘗試通過自動調整大小。 –