저는 car 만들기 배열에서 두 번째와 세 번째 값을 가져오고 아래 함수에서 반환하려고합니다. 나는 cell.title.text = carmake[1...2][indexPath.row]
과 cell.title.text = carmake[indexPath.[1...2]]
을 시도했지만 그 중 누구도 맞지 않습니다. 당신이 그들을 결합하려는 경우 시도 할 수 있습니다, 나에게indexpath.row의 배열에서 특정 값을 얻습니다.
carmake = ["hi","hello","how are you","i am good"]
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = viewcontrol.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! jobtypeCollectionViewCell
cell.title.text = carmake[indexPath.row]
return cell
}
귀하의 질문에 (적어도 나에게) 명확하지 않다. 수집보기가있는 항목의 수와 각 항목의 제목은 무엇입니까? –
콜렉션 뷰에는 carmake 배열의 항목이 두 개 있어야하지만 셀 제목은 "hello", "how are you"여야합니다. carmake 배열에 4 가지 값이 있지만 4 가지 중에서 2 가지 값만 가져 오려고합니다. – jakson