Answers for "swift tableview cell"

1

swift uitableview insert cell

self.yourArray.append(msg)

self.tblView.beginUpdates()
self.tblView.insertRows(at: [IndexPath.init(row: self.yourArray.count-1, section: 0)], with: .automatic)
self.tblView.endUpdates()
Posted by: Guest on March-09-2020
0

write into table view swift 5

import UIKit

// First, Consider using a UITableViewController
class ToDoListViewController: UITableViewController {
    // 1. Define an array with to-do list items
    let itemArray = ["Study Swift", "Buy Eggs", "Read a newspapper"]

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    // 2. Return a number of rows according to the number of array elements 
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return itemArray.count
    }
    // 3. Assign the tableView cell and title
   override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "ToDoListCell", for: indexPath)
        cell.textLabel?.text = itemArray[indexPath.row]
        return cell
    }
}
Posted by: Guest on May-24-2021

Code answers related to "swift tableview cell"

Code answers related to "Swift"

Browse Popular Code Answers by Language