라이브러리를 사용하지 않고 사용자 정의 셀을 사용하여 색인 경로에서 행에 하위 행을 추가하려고합니다.didselectRowAt (Swift 3) 서브 루틴을 추가 할 수있는 방법
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayEnum.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var CellTB: UITableViewCell!
let cell = tableView.dequeueReusableCell(withIdentifier: "enumCell", for: indexPath)as! UserFlagTableViewCell
cell.UserflagLabel.text = arrayEnum[indexPath.row].rawValue
CellTB = cell
// let cell1 = tableView.dequeueReusableCell(withIdentifier: "freeTextCell", for: indexPath)as! FreeTextTableViewCell
// cell1.sendButton.addTarget(self, action: Selector("sendUserflagEvent:"), for: .touchUpInside)
// CellTB = cell1
return CellTB
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.tableView.insertRows(at: [IndexPath(row: UserFlagType.userFlagTypes.count-1, section: 0)], with: .automatic)
self.tableView.beginUpdates()
self.tableView.endUpdates()
}
: 내가 이것을 시도 같은
입니다 나타납니다있는 셀 : 나는 셀을 선택하면
는 다른 셀이 작업은 각 셀 시 반복되고,이 셀 아래에 나타납니다
내가 1 절 이 난 6 행
하는 대신 array.count에 1을 추가
을 반영하고 어떻게 표시 할 수 있습니다 새로운 셀 ?? 이유 : '행 6을 섹션 0에 삽입하려고 시도하지만 업데이트 후 섹션 0에 여섯 개의 행만 있습니다.' libC++ abi.dylib : NSException 유형의 캐치되지 않는 예외로 종료합니다. –
IndexPath가 0에서 시작하고 사용자가 array.count, 1부터 시작. 그래서 ... array.count - 1 할 필요가. 나는 대답을 편집 할 것입니다. – Mellao
열거 형 목록 (6 열거 형)을 테이블보기로 만들고 나는 새 맞춤형 셀이 나타나는 셀을 선택할 때 (단추와 텍스트를 보내는 방법)를 원한다. 나는 어떻게하는지 모르겠다. 그리고 수 없습니다 배열을 열거 할 수 있습니다 –