0

시간별 날씨를 표시하려는 컬렉션 뷰가 있습니다. 셀을로드하는 데 문제가있는 것 같습니다. 그리고 어떤 이유로 스크롤하여 전달한 다음 완전히 다시로드합니다. 컬렉션 뷰를 스크롤하기 전에 모든 제약 조건이 작동하지 않고 하나의 레이블에 정보가 표시되지 않습니다.UICollectionView가 스크롤 할 때까지 완전히로드되지 않습니다.

Before scrolling 비동기 당신의 세포를 채우는 같은 다음 mycollectionview을 추가하는 경우

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { 
    // #warning Incomplete implementation, return the number of sections 
    return 1 
} 


func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
    // #warning Incomplete implementation, return the number of items 
    return newhourlyWeather.count 
} 

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! hourlyWeatherCell 

    // Configure the cell 

    let hWeather = newhourlyWeather[indexPath.row] 

    if let HourlyTemp = hWeather.temperatureh { 
     cell.temperatureHLabel.text = "\(HourlyTemp)º" 
    } 

    if let HourlyTime = hWeather.convertedTimeH { 
     cell.timeHLabel.text = "\(HourlyTime)" 
    } 

    if let HourlyRain = hWeather.precipProbabilityh { 
     cell.rainChanceHLabel.text = "\(HourlyRain)%" 
    } 

    cell.iconhView.image = hWeather.iconh 

    return cell 

    self.collectionView.reloadData() 
} 
+0

어떤 코드가 필요한지 알고 싶습니다. – zombie

+0

제약 조건에 대한 코드 및 추가 정보가 없으면이 질문에 대한 답변을 얻을 수 없습니다. – vikingosegundo

+0

업데이트 된 질문 @vikingosegundo – fellowProgrammer

답변

3

이 보인다 (이것이 내가 세포가 같이하는 방법입니다) 스크롤 한 후

After scrolling (this is how I want the cells to look like)

스크롤하기 전에. 마지막에 reloadData().

1

return cell 앞에 cell.layoutIfNeeded()을 추가하여 문제를 해결했습니다. 아무 것도 스크롤하지 않고 예상대로로드!

+0

제약 문제가 있다고 생각합니다. – Jeff

관련 문제