Commit ab081e88 authored by giovannicariglia's avatar giovannicariglia

worked on different View Demos

parent a3751a14
......@@ -7,6 +7,13 @@
objects = {
/* Begin PBXBuildFile section */
9A588BEF25A75AF40012990D /* PopUpVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A588BEE25A75AF40012990D /* PopUpVC.swift */; };
9A588BF225A75D910012990D /* OptionsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A588BF125A75D910012990D /* OptionsVC.swift */; };
9A6395C425A6FD580030AB0D /* MyColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6395C325A6FD580030AB0D /* MyColor.swift */; };
9A6395C825A6FFDF0030AB0D /* MasterTableVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6395C725A6FFDF0030AB0D /* MasterTableVC.swift */; };
9A6395CD25A725200030AB0D /* SplitVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6395CC25A725200030AB0D /* SplitVC.swift */; };
9A6395D525A7295C0030AB0D /* DetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6395D425A7295C0030AB0D /* DetailVC.swift */; };
9A6395DC25A742990030AB0D /* MasterDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6395DB25A742990030AB0D /* MasterDetailViewModel.swift */; };
9A93295125A0FBC90025FC97 /* DashboardController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A93295025A0FBC90025FC97 /* DashboardController.swift */; };
9A93295425A0FBFF0025FC97 /* DetailsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A93295325A0FBFF0025FC97 /* DetailsController.swift */; };
9AB7E3E6259D06C8008F9DD8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AB7E3E5259D06C8008F9DD8 /* AppDelegate.swift */; };
......@@ -15,12 +22,21 @@
9AB7E3ED259D06C8008F9DD8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9AB7E3EB259D06C8008F9DD8 /* Main.storyboard */; };
9AB7E3EF259D06CB008F9DD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9AB7E3EE259D06CB008F9DD8 /* Assets.xcassets */; };
9AB7E3F2259D06CB008F9DD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9AB7E3F0259D06CB008F9DD8 /* LaunchScreen.storyboard */; };
9AD0FAD025A6067C00E15817 /* TableDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AD0FACF25A6067C00E15817 /* TableDemoViewController.swift */; };
9AE1463125A87300005104EE /* PopupCodeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AE1463025A87300005104EE /* PopupCodeVC.swift */; };
9AEA96C725A2168D00EC932D /* EditorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AEA96C625A2168D00EC932D /* EditorController.swift */; };
9AF326BD25A275740038E5B4 /* NaviTestController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF326BC25A275740038E5B4 /* NaviTestController.swift */; };
9AF326C025A280600038E5B4 /* TestViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF326BF25A280600038E5B4 /* TestViewModel.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
9A588BEE25A75AF40012990D /* PopUpVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopUpVC.swift; sourceTree = "<group>"; };
9A588BF125A75D910012990D /* OptionsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionsVC.swift; sourceTree = "<group>"; };
9A6395C325A6FD580030AB0D /* MyColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MyColor.swift; path = "../../../../../../Library/Mobile Documents/com~apple~CloudDocs/_dev/Swift/__Buch-Dateien/swift5-beispielprogramme-teil1/17/ios-split/ios-split/MyColor.swift"; sourceTree = "<group>"; };
9A6395C725A6FFDF0030AB0D /* MasterTableVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTableVC.swift; sourceTree = "<group>"; };
9A6395CC25A725200030AB0D /* SplitVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SplitVC.swift; path = "../../../../../../../Library/Mobile Documents/com~apple~CloudDocs/_dev/Swift/__Buch-Dateien/swift5-beispielprogramme-teil1/17/ios-split/ios-split/SplitVC.swift"; sourceTree = "<group>"; };
9A6395D425A7295C0030AB0D /* DetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailVC.swift; sourceTree = "<group>"; };
9A6395DB25A742990030AB0D /* MasterDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterDetailViewModel.swift; sourceTree = "<group>"; };
9A93295025A0FBC90025FC97 /* DashboardController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardController.swift; sourceTree = "<group>"; };
9A93295325A0FBFF0025FC97 /* DetailsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsController.swift; sourceTree = "<group>"; };
9AB7E3E2259D06C8008F9DD8 /* Test Login.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test Login.app"; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -31,6 +47,8 @@
9AB7E3EE259D06CB008F9DD8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9AB7E3F1259D06CB008F9DD8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9AB7E3F3259D06CB008F9DD8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9AD0FACF25A6067C00E15817 /* TableDemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableDemoViewController.swift; sourceTree = "<group>"; };
9AE1463025A87300005104EE /* PopupCodeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupCodeVC.swift; sourceTree = "<group>"; };
9AEA96C625A2168D00EC932D /* EditorController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorController.swift; sourceTree = "<group>"; };
9AF326BC25A275740038E5B4 /* NaviTestController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NaviTestController.swift; sourceTree = "<group>"; };
9AF326BF25A280600038E5B4 /* TestViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewModel.swift; sourceTree = "<group>"; };
......@@ -47,6 +65,27 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
9A588BEC25A75AC00012990D /* PopOver */ = {
isa = PBXGroup;
children = (
9A588BEE25A75AF40012990D /* PopUpVC.swift */,
9A588BF125A75D910012990D /* OptionsVC.swift */,
9AE1463025A87300005104EE /* PopupCodeVC.swift */,
);
path = PopOver;
sourceTree = "<group>";
};
9A6395C625A6FF490030AB0D /* MasterDetailModule */ = {
isa = PBXGroup;
children = (
9A6395DB25A742990030AB0D /* MasterDetailViewModel.swift */,
9A6395CC25A725200030AB0D /* SplitVC.swift */,
9A6395C725A6FFDF0030AB0D /* MasterTableVC.swift */,
9A6395D425A7295C0030AB0D /* DetailVC.swift */,
);
path = MasterDetailModule;
sourceTree = "<group>";
};
9AB7E3D9259D06C8008F9DD8 = {
isa = PBXGroup;
children = (
......@@ -66,6 +105,9 @@
9AB7E3E4259D06C8008F9DD8 /* Test Login */ = {
isa = PBXGroup;
children = (
9A588BEC25A75AC00012990D /* PopOver */,
9A6395C625A6FF490030AB0D /* MasterDetailModule */,
9A6395C325A6FD580030AB0D /* MyColor.swift */,
9AB7E3E5259D06C8008F9DD8 /* AppDelegate.swift */,
9AB7E3E7259D06C8008F9DD8 /* SceneDelegate.swift */,
9AB7E3E9259D06C8008F9DD8 /* ViewController.swift */,
......@@ -78,6 +120,7 @@
9AEA96C625A2168D00EC932D /* EditorController.swift */,
9AF326BC25A275740038E5B4 /* NaviTestController.swift */,
9AF326BF25A280600038E5B4 /* TestViewModel.swift */,
9AD0FACF25A6067C00E15817 /* TableDemoViewController.swift */,
);
path = "Test Login";
sourceTree = "<group>";
......@@ -153,13 +196,22 @@
buildActionMask = 2147483647;
files = (
9A93295125A0FBC90025FC97 /* DashboardController.swift in Sources */,
9A6395CD25A725200030AB0D /* SplitVC.swift in Sources */,
9A6395D525A7295C0030AB0D /* DetailVC.swift in Sources */,
9AF326BD25A275740038E5B4 /* NaviTestController.swift in Sources */,
9A6395C825A6FFDF0030AB0D /* MasterTableVC.swift in Sources */,
9AF326C025A280600038E5B4 /* TestViewModel.swift in Sources */,
9AB7E3EA259D06C8008F9DD8 /* ViewController.swift in Sources */,
9AD0FAD025A6067C00E15817 /* TableDemoViewController.swift in Sources */,
9A6395C425A6FD580030AB0D /* MyColor.swift in Sources */,
9A93295425A0FBFF0025FC97 /* DetailsController.swift in Sources */,
9AB7E3E6259D06C8008F9DD8 /* AppDelegate.swift in Sources */,
9A6395DC25A742990030AB0D /* MasterDetailViewModel.swift in Sources */,
9A588BEF25A75AF40012990D /* PopUpVC.swift in Sources */,
9AEA96C725A2168D00EC932D /* EditorController.swift in Sources */,
9AE1463125A87300005104EE /* PopupCodeVC.swift in Sources */,
9AB7E3E8259D06C8008F9DD8 /* SceneDelegate.swift in Sources */,
9A588BF225A75D910012990D /* OptionsVC.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -16,8 +16,8 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "51"
endingLineNumber = "51"
landmarkName = "testLogin()"
landmarkType = "7">
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
......
......@@ -10,10 +10,19 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
// var masterDetailSplitVC: UISplitViewController?
// var masterDetailNC: MasterDetailNC?
// var masterDetailTVC: MasterTableVC?
// var masterDetailDetailVC: DetailVC?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// masterDetailSplitVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(identifier: "splitVC") as UISplitViewController
// masterDetailNC = masterDetailSplitVC?.viewControllers.first as? MasterDetailNC
// masterDetailTVC = masterDetailNC?.topViewController as? MasterTableVC
// masterDetailDetailVC = masterDetailSplitVC?.viewControllers.last as? DetailVC
return true
}
......
This diff is collapsed.
//
// DetailVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class DetailVC: UIViewController {
@IBOutlet weak var lblColor: UILabel!
@IBOutlet weak var viewColor: UIView!
var myColor: MyColor? {
didSet(oldcolor) {
refresh()
}
}
override func viewDidLoad() {
super.viewDidLoad()
MasterDetailViewModel.getInstance.detailVC = self
refresh()
}
private func refresh() {
if MasterDetailViewModel.getInstance.selectedColor != nil {
let color = MasterDetailViewModel.getInstance.selectedColor!
lblColor?.text = color.name
viewColor?.backgroundColor = color.color
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// MasterDetailNC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class MasterDetailNC: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// TestViewModel.swift
// Test Login
//
// Created by Giovanni Cariglia on 03.01.21.
//
import Foundation
class MasterDetailViewModel {
var colors = MyColor.makeDefault()
var selectedColor: MyColor?
var detailVC: DetailVC?
var splitVC: SplitVC?
static let getInstance: MasterDetailViewModel = {
let instance = MasterDetailViewModel()
instance.selectedColor = instance.colors[0]
return instance
}()
}
//
// MasterTableVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class MasterTableVC: UITableViewController {
let mycolors = MyColor.makeDefault()
let myApp = UIApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
self.clearsSelectionOnViewWillAppear = false
// nicht befüllte Tabellen Zeilen nicht anzeigen (keine leeren Zeilen unten)
self.tableView.tableFooterView = UIView(frame: CGRect.zero)
// Eintrag 1 per Code wählen
let selectedIndex = IndexPath(row: 0, section: 0)
self.tableView.selectRow(at: selectedIndex, animated: true, scrollPosition: .top)
MasterDetailViewModel.getInstance.selectedColor = mycolors[0]
if MasterDetailViewModel.getInstance.detailVC != nil {
MasterDetailViewModel.getInstance.detailVC!.myColor = mycolors[0]
}
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
// override func numberOfSections(in tableView: UITableView) -> Int {
// // #warning Incomplete implementation, return the number of sections
// return 0
// }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return mycolors.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
cell.textLabel?.text = mycolors[indexPath.row].name
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("Listenauswahl, Row = \(indexPath.row)")
MasterDetailViewModel.getInstance.selectedColor = mycolors[indexPath.row]
if MasterDetailViewModel.getInstance.detailVC != nil {
MasterDetailViewModel.getInstance.detailVC?.myColor = mycolors[indexPath.row]
if MasterDetailViewModel.getInstance.splitVC != nil {
MasterDetailViewModel.getInstance.splitVC!.showDetailViewController(MasterDetailViewModel.getInstance.detailVC!, sender: nil)
}
}
// myApp.masterDetailSplitVC?.showDetailViewController(myApp.masterDetailDetailVC!, sender: nil)
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// TesstDetailVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class TesstDetailVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// OptionsVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class OptionsVC: UIViewController, UIPopoverPresentationControllerDelegate {
@IBOutlet weak var lblAlertAntwort: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let dest = segue.destination as? PopUpVC,
let popPC = dest.popoverPresentationController{
popPC.delegate = self
}
}
// funktioniert nur mit popPC.delegate = self
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
@IBAction func onOpenPopupCklick(_ sender: UIButton) {
let popupVC = storyboard?.instantiateViewController(identifier: "popupTestCode") as! PopupCodeVC
popupVC.modalPresentationStyle = .popover
let popPC = popupVC.popoverPresentationController!
popPC.sourceView = sender
popPC.sourceRect = sender.bounds
popPC.permittedArrowDirections = .up
popPC.delegate = self
present(popupVC, animated: true, completion: nil)
}
@IBAction func unwindToOptions(_ segue:UIStoryboardSegue) {
if let src = segue.source as? PopupCodeVC {
}
}
@IBAction func onBtnAlertQuestionClick(_ sender: UIButton) {
let alert = UIAlertController(title: "Frage", message: "Sind Sie sicher?", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Nein", style: .default, handler: {
(_) in self.lblAlertAntwort.text = "Nein"
}))
alert.addAction(UIAlertAction(title: "Ja", style: .default, handler: {
(_) in self.lblAlertAntwort.text = "Ja"
}))
alert.addAction(UIAlertAction(title: "Unsicher", style: .default, handler: {
(_) in self.lblAlertAntwort.text = "Unsicher"
}))
present(alert, animated: true, completion: nil)
}
@IBAction func onBtnAlert2Click(_ sender: UIButton) {
let alert = UIAlertController(title: "Datensatz löschen", message: "Wollen Sie den Datensatz wirklich löschen?", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Abbrechen", style: .cancel, handler: {
(_) in self.lblAlertAntwort.text = "Abbrechen"
}))
alert.addAction(UIAlertAction(title: "Löschen", style: .destructive, handler: {
(_) in self.lblAlertAntwort.text = "Löschen"
}))
present(alert, animated: true, completion: nil)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// PopUpVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 07.01.21.
//
import UIKit
class PopUpVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// PopupCodeVC.swift
// Test Login
//
// Created by Giovanni Cariglia on 08.01.21.
//
import UIKit
class PopupCodeVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func onBtnOkClick(_ sender: Any) {
dismiss(animated: true, completion: {
print("Popup geschlossen!")
})
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// TableDemoViewController.swift
// Test Login
//
// Created by Giovanni Cariglia on 06.01.21.
//
import UIKit
class TableDemoViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// tableView.delegate = self
// tableView.dataSource = self
// nicht befüllte Tabellen Zeilen nicht anzeigen (keine leeren Zeilen unten)
tableView.tableFooterView = UIView(frame: CGRect.zero)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
// Eintrag 5 per Code wählen
let selectedIndex = IndexPath(row: 4, section: 0)
tableView.selectRow(at: selectedIndex, animated: true, scrollPosition: .top)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return TestViewModel.getInstance.testStringList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
// Eigenschaften der Zelle einstellen und zurückgeben
cell.textLabel!.text = TestViewModel.getInstance.testStringList[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(TestViewModel.getInstance.testStringList[indexPath.row])
}
}
//extension ViewController: UITableViewDataSource, UITableViewDelegate {
// func numberOfSections(in tableView: UITableView) -> Int {
// // Die Liste hat nur einen Abschnitt. In diesem Fall können
// // Sie auf die Methode ganz verzichten.
// return 1
// }
// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// // der einzige Abschnitt der Liste hat mydata.count Elemente
// return TestViewModel.getInstance.testStringList.count
// }
// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// // liefert eine Zelle
// let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
// // Eigenschaften der Zelle einstellen und zurückgeben
// cell.textLabel!.text = TestViewModel.getInstance.testStringList[indexPath.row]
// return cell
// }
//}
......@@ -9,6 +9,7 @@ import Foundation
class TestViewModel {
var testMsg = ""
var testStringList = ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6", "Test 7", "Test 8", "Test 9"]
static let getInstance: TestViewModel = {
let instance = TestViewModel()
// setup code
......
......@@ -12,7 +12,7 @@ class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var tvUsername: UITextField!
@IBOutlet weak var tvPassword: UITextField!
@IBOutlet weak var labelInfo: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment