En cours

Display UICollectionView Cell height depending on the height of the image

Hi,

Can someone help me to correct this code so i can get the correct uicollectionview cell depend on the dynamic height. func collectionView(_ collectionView: UICollectionView,

layout collectionViewLayout: UICollectionViewLayout,

sizeForItemAt indexPath: IndexPath) -> CGSize {

var ratio = 1.500

let Arr = photoArray[[login to view URL]].components(separatedBy: ".")

let url11 = URL(string: appUrl + "feednews/large/" + photoArray[[login to view URL]])

let fileURL = appUrl + "feednews/large/" + photoArray[[login to view URL]]

if Arr[1] == "mov" {

[login to view URL](qos: .background).async {

let asset = AVAsset(url: URL(string: fileURL)!)

let assetImgGenerate = AVAssetImageGenerator(asset: asset)

[login to view URL] = true

let time = CMTimeMakeWithSeconds(Float64(1), preferredTimescale: 1)

do {

let img = try [login to view URL](at: time, actualTime: nil)

let thumbnail = UIImage(cgImage: img)

[login to view URL] {

ratio = Double(CGFloat([login to view URL]))

}

} catch {

}

}

print("ratio " + String(ratio))

return CGSize(width: [login to view URL] - 2, height: ([login to view URL] - 2) * CGFloat(ratio))

}

else {

[login to view URL](qos: .background).async {

if let imageSource = CGImageSourceCreateWithURL(url11! as CFURL, nil){

if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary? {

let pixelWidth = imageProperties[kCGImagePropertyPixelWidth] as! CGFloat

let pixelHeight = imageProperties[kCGImagePropertyPixelHeight] as! CGFloat

ratio = Double(CGFloat(pixelHeight/pixelWidth))

}

}

}

print("ratio " + String(ratio)) ===> always shows as 1.5??? Please correct this

return CGSize(width: [login to view URL] - 2, height: ([login to view URL] - 2) * CGFloat(ratio))

}

}

Compétences : Swift

en voir plus : restrict image height java, resize image height width, virtuemart product display page show different image, display flash sharepoint banner image, sharepoint image web part change image height, css image height, javascript image height width max, javascript image height width, display bynary data single image control aspnet, ie6 image height, javascript image height, google chrome image height problem, cell background image center html, css center cell background image, maximum image height, javascript resize image height screen height, custom categories image height oscommerce, display images run time image button server mappath folder, expression image height, display cell comment image vba userform

Concernant l'employeur :
( 14 commentaires ) San Jose, United States

Nº du projet : #22008942

Décerné à:

ThisIsPouya

Hello, I can fix your problem with size of CollectionViewCell not being flexible. I am an iOS app developer based on Swift and Xcode. I have two commercial apps on App Store, WikiMedicine and Street Explorer. I also h Plus

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(3 Commentaires)
4.2

3 freelance font une offre moyenne de $60 pour ce travail

waterflowertie

Hi! I’ve read your job description carefully and I am very interested in your project. I am sure that I can finish this project of 100% result in short time with the reasonable budget. I have rich experience in develop Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(11 Commentaires)
4.6
evgenypushkarev

Hello It's a pleasure to meet you. I am an experienced iOS app developer and have worked on many of existing projects for maintains and updates. I understand someone's code very well and have strong debug experience t Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(2 Commentaires)
1.4