제 생각에는 tableview의 모든 행이 당신이 채울 수있는 일종의 작업입니다. 그리고 언제든지 appView를 열 때마다 tableView에서 선이 있어야합니다. (그림에서 보는 바와 같이) 섹션의 행 수를 알지 못합니다. (신속한)
또한 행을 추가 할 수있는 버튼이 있습니다. 그러나 섹션의 행 수를 어떻게 알 수 있는지 잘 모릅니다. 당신은 (내 코드에서 내가 이해할 수없는 순간 댓글을 달았습니다)? 그것으로 저를 도와주세요
class TaskSecondViewController: UIViewController,UITableViewDataSource{
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
self.tableView.separatorColor = UIColor.clear
@IBAction func insert_rows(_ sender: Any) {
let indexPath = IndexPath(row: 1, section: 1) // Don't know what to write in "row"
self.tableView.insertRows(at: [indexPath], with: .top)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1 // Here also
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TaskTableViewCell
return cell
}
}
어딘가에 당신이 당신의 행을 저장해야합니다 . 그리고이 데이터 소스는 저장 한 항목, 즉 섹션의 행 수를 확실히 나타낼 수 있습니다. – idmean