내가 보통이 같은 UI 컬렉션 뷰를 구현 스위프트에 새로 온 사람과 목적 C.에 대한 사전 경험이없는 :UI 컬렉션에 텍스트 필드를 포함하는 방법 셀을보고 텍스트를 배열에 저장 하시겠습니까?
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
let reuseIdentifier = "cell"
var items = ["1", "2", "3" ... "100"]
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MyCollectionViewCell
cell.myLabel.text = self.items[indexPath.item]
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
// handle tap events
print("You selected cell #\(indexPath.item)!")
}
}
하지만 텍스트 필드에이 방법의 조금 생각이없는 그 셀은 선언 된 배열 (항목)의 숫자가 아닙니다. 그리고 배열에 입력 된 텍스트를 어떻게 저장할 수 있습니까?
P.S이 코드를 기대하지 않고 게시하는 것이지만 (나에게 많은 도움이 되겠지만) 어떻게해야하는지에 대한 지침이나 웹 링크가 있습니다.