Vorlesungen
  Download     DBS     Sprachen     Oberflächen     File Formats     Impressum     Datenschutz  
1. Sem
2. Sem
3. Sem
4. Sem
5. Sem
iOS-SwiftUI
iOS
Android und JetPack
Wahlpflicht-SoSe
Wahlpflicht-WiSe
Projektwochen
Allgemein:
Startseite
Vorlesungen
Labore
Sinnvolle Programme
Lineare Regression
GUI-Entwurfsarbeit
Single-Format
Design Pattern-Termine
Observer1
Bsp2
Json-Array
Json-Dialogelemente
Webtechnologien

uiTableView

Delegate Funktionen


class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

 @IBOutlet var tableview: UITableView!
 var cities : [City] = []

 override func viewDidLoad() {
  super.viewDidLoad()
  self.navigationItem.rightBarButtonItem = self.editButtonItem
  cities = CitiesDB.loadCitiesIntern()
  tableview.delegate=self
  tableview.dataSource=self
 }

  // count of columns 
 func numberOfSections(in tableView: UITableView) -> Int {
  return 1
 }

  // count of rows
 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  return cities.count
 }


 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  //let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
  //let cell: UITableViewCell = UITableViewCell(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: "cell")
  let cell: UITableViewCell = UITableViewCell(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: "reuseIdentifier")

   // Configure the cell...
   let row = (indexPath as NSIndexPath).row
   let city:City = cities[ row ]
   cell.textLabel?.text = city.name
   cell.detailTextLabel?.text = city.remark
   return cell
  }
} 



prepare-Methode im 2. ViewController


// diese Methode wird im zweiten ViewController benötigt
// sie wird aufgerufen, bevor exit aufgerufeb wird

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
   city.name=tname.text!
} 



createStudenten (TableView)
Klassen für TableView