NSCollectionViewItem에 동적 크기를 지정하려고합니다. 나는 그들에게 그들의 내용과 내가 정의한 제약에 의해 결정되는 크기를 갖기를 원한다. 예외가 발생NSCollectionViewItem의 동적 크기
extension ViewController : NSCollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize{
let item = collectionView.item(at: indexPath)
if let viewItem = item as NSCollectionViewItem? {
return viewItem.view.fittingSize
}
return NSSize(width: 200, height: 100)
}
}
: 나는 다음 NSCollectionView 보유하고 내의 ViewController에 추가해야 그 내용은
. 그것이 어디에서 온
An uncaught exception was raised
*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]
나는 보지 않는다, 나는 그것을 잡으려고 시도했지만 엑스 코드는 item(at:)
이 예외가 발생하지 않는 것을 말한다.
편집 :하지만 사실 그것은 내가 예외 중단 점을했고, 누군가는 다른 생각을 가지고 않습니다 애플 버그 repport을 보내는 옆에 item(at:)
에 침입, 무엇입니까? 그리고 (at :)는 오류를 던지기로되어 있지 않기 때문에 블록 캐치는 효과가 없습니다.
나는'item (at :)'이 예외를 보내려고했다. – Jerome