Post

Replies

Boosts

Views

Activity

Reply to Pass Data between two View Controller
I call this function right before I perform the segue with code // function with code for loading the data from core data print("loaded  " +	caption)                     self.caption = caption                     self.size = size as! String                     self.text = text as! String                 }             }             print ("fertig")         } catch  {             print(error)         }         let vc =  ThirdViewController()         vc.initializer(caption : caption, size : size, text : text) //        Segue wird ausgeführt         performSegue(withIdentifier: "shownext", sender: indexesToRedraw)     }
Dec ’20
Reply to Persistent data with Core Data
Thanks for your answer! I am running the app on the iOS Simulator, the saved date is gone. I saved new data and closed and reopened xcode and the saved data were still there. Maybe it was just because of the update? @Claude31 I close the app sometimes in the simulator and sometimes in xcode. func saveProcedures(){         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else{             return         }         let context = appDelegate.persistentContainer.viewContext         let entityname = "Fruits"         guard let newEnity = NSEntityDescription.entity(forEntityName: entityname, in: context) else {             return         }         let newProcedure = NSManagedObject(entity: newEnity, insertInto: context)         let size = "5-7cm"         let caption = "Orange"         newProcedure.setValue(size, forKey: "size")         newProcedure.setValue(caption, forKey: "caption")         do {             try context.save()             print("saved fruit")         } catch  {             print(error)         }     }     func loadProcedure (){         guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else{             return         }         let context = appDelegate.persistentContainer.viewContext         let entityName = "Fruits"         let request = NSFetchRequest<NSFetchRequestResult>(entityName: entityName)         do {             let results = try context.fetch(request)             for r in results{                 if let result = r as? NSManagedObject{                     guard let importance = result.value(forKey: "size") as? String else {                         return                     }                     guard let protocol_caption = result.value(forKey: "caption") as? String else {                         return                     }                     self.fruitsArray.append(caption)                     print("loaded")                 }             }             print ("done")             print (fruitsArray)         } catch  {             print(error)         }     }
Dec ’20
Reply to Remove Navigation Controller behavior from one View
I want a to do a popover window and that works if I have no Navgation Controller, because the new View appears over the old one. B1->B2 If I set the background color of B2 to Clear Color and put a Label with a blue background color on it. The program does what I want. The tricky part now is that I want to include this simple behavior to my project, which needs a NavController.
Dec ’20
Reply to Tab Bar Controller, Home Button
Xcode "says" this function does not exist. Where exactly did you place this function? In the TabBarController or in the ViewController from A1? import UIKit class MyTabBarViewController: UITabBarController {     override func viewDidLoad() {         super.viewDidLoad()     }     override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {         let rootView = self.viewControllers         [self.selectedIndex] as! UINavigationController         rootView.popToRootView // here the editor says that it does not work/exist //     } I made a class for the tab bar Controller and connected it to the storyboard. And what do you mean with IB ?
Nov ’20
Reply to Tab Bar Controller, Home Button
Hi, thank you for your answer! I go from A2-> using TabBar clicking on B -> B1->B2-> usingTabBar clicking on A -> and now get to A2, but I always want my TabBar to go to A1/B1, your first solution might work, but "popToRootViewController" does not work, what do you mean by that ?
Nov ’20
Reply to Change color of table view cell when clicked
        let indexesToRedraw = [indexPath]         selectedIndex = indexPath         array[indexPath.row] = true         tableView.reloadRows(at: indexesToRedraw, with: .fade)         sleep(1)         array[indexPath.row] = false         tableView.reloadRows(at: indexesToRedraw, with: .fade)         performSegue(withIdentifier: "shownext", sender: indexesToRedraw)    }         let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)         cell.textLabel?.text = array[indexPath.row]         if selectedIndex == indexPath {             if array[indexPath.row] {                 cell.backgroundColor = UIColor.black             }             else{                 cell.backgroundColor = UIColor.blue             }             cell.setSelected(true, animated: true)         } I basically did what you proposed, but the cell still turns light grey when clicked, I think somewhere in my code I did a basic mistake, but I can not figure it out. Thanks a lot for helping me this far.
Nov ’20
Reply to Change color of table view cell when clicked
Unfortunately it still does not work. Maybe because I worked with the storyboard ? I linked the table view cell to another view, it works, but if I click on the the table view cell it gets light grey for just a moment before it shows the next page. Thanks to you it changes back to the original color when I go back. tableView.reloadRows(at: indexesToRedraw, with: .fade) was the line of code, which caused that. Should I try to get rid of the link in the storyboard and try it with code ?
Nov ’20