정적 tableView를 만들고 CoreData에 각 tableViewCell (모든 셀은 다른 사용자 정의 tableViewCells 임)의 데이터를 저장하려고합니다. 버튼 누르기에서 모든 TableViewCell을 반복하는 방법은 무엇입니까? Storyboard를 사용하지 않기 때문에 IBOutlets가 없습니다.스위프트 : 버튼 누름시 모든 tableViewRow를 반복하는 방법
편집 : 죄송합니다, 내 문제를 지정해야합니다. 아래 코드를 참조하십시오. 3 개의 CustomCell이 있습니다. FirstCustomCell에는 Textfield, SecondCustomCell에 UIPickerView, ThirdCustomCell에 UIDatePicker가 포함되어 있습니다. 컨트롤러에는 saveButton()도 포함되어 있습니다. 단추를 누르면 TextField, UIPickerView 및 UIDatePicker에서 입력을 가져오고 싶습니다.
//TableViewController
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.row {
case 0:
return tableView.dequeueReusableCell(withIdentifier: cellId1) as! FirstCustomCell //includes a UITextField
case 1:
return tableView.dequeueReusableCell(withIdentifier: cellId2) as! SecondCustomCell //includes a UIPickerView
case 2:
return tableView.dequeueReusableCell(withIdentifier: cellId3) as! ThirdCustomCell //includes a UIDatePicker
default:
return UITableViewCell(style: .default, reuseIdentifier: nil)
}
}
어떻게 내가 내 TableViewController에 saveButton()에서 텍스트 필드, UIPickerView 및 UIDatePicker에서 입력에 액세스 할 수 있습니다 ?
어떻게 셀 템플릿을 정의합니까? XIB 파일로? –
클래스 UITableViewCell – eberhapa
서브 클래 싱 좋아,하지만 어떻게 세포의 사용자 정의 필드가 정의되어 있습니까? –