Post

Replies

Boosts

Views

Activity

Reply to Localization and tap gesture
2 years later… I finally found here inspiration here for something very close to what I wanted: https://stackoverflow.com/questions/28152526/how-do-i-open-phone-settings-when-a-button-is-clicked Button action to switch language: &#9;&#9;@objc func openSettings() { &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return } &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;if UIApplication.shared.canOpenURL(settingsUrl) { &#9;&#9;&#9;&#9;&#9;&#9;UIApplication.shared.open(settingsUrl, completionHandler: nil) &#9;&#9;&#9;&#9;} &#9;&#9;} &#9;&#9; &#9;&#9;@IBAction func toggleLanguagePopover() { &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;var languages : [Language] = [] &#9;&#9;&#9;&#9;for country in Language.allLanguages { // I have defined the list of languages the app is localised for &#9;&#9;&#9;&#9;&#9;&#9;languages.append(country) &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;var anAction : UIAlertAction &#9;&#9;&#9;&#9;var alertStyle = UIAlertController.Style.alert &#9;&#9;&#9;&#9;let alertController = UIAlertController( &#9;&#9;&#9;&#9;&#9;&#9;title: NSLocalizedString("Language", comment: ""), &#9;&#9;&#9;&#9;&#9;&#9;message: NSLocalizedString("Select a language, comment: "toggleLanguagePopover"), preferredStyle: alertStyle)&#9; &#9;&#9;&#9;&#9;for i in 0..<languages.count { &#9;&#9;&#9;&#9;&#9;&#9;anAction = UIAlertAction(title: languages[i].flag + " " + languages[i].fullname, style: .default, handler: { (action) -> Void in self.openSettings()} ) &#9;&#9;&#9;&#9;&#9;&#9;anAction.isEnabled = Global.shared.systemLanguage != Language.allLanguages[i] // Button for the already selected language is disabled &#9;&#9;&#9;&#9;&#9;&#9;alertController.addAction(anAction) &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9; &#9;&#9;&#9; let cancelAction = UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .destructive, handler: nil) &#9;&#9;&#9;&#9;&#9;&#9;alertController.addAction(cancelAction) &#9;&#9;&#9;&#9;present(alertController, animated: true, completion: nil) &#9;&#9;} This brings you to the app settings page with direct access to preferred languages list. Click on language and return to your app from the navigation button. You have switched the app language. It's very fast. Only caveat, the device language does not change, so settings remain displayed in device's language. But that's a really minor annoyance.
Mar ’21
Reply to Not following app guidelines and rejected build.
You got a lot of suggestions in SO. Did you try them ? Crash log seems to show problem is in InitialViewController / viewDidAppear Have you checked both segues: loginSegue and viewDashBoard Which VC do they lead to ? import UIKit class InitialViewController: UIViewController { &#9;&#9;override func viewDidLoad(){ &#9;&#9;&#9;&#9;super.viewDidLoad() &#9;&#9;} &#9;&#9; &#9;&#9;override func viewWillAppear(_ animated: Bool) { &#9;&#9;&#9;&#9;self.navigationController?.navigationBar.barTintColor = #colorLiteral(red: 0.2196078431, green: 0.4705882353, blue: 0.9137254902, alpha: 1) &#9;&#9;&#9;&#9;self.navigationController?.navigationBar.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white] &#9;&#9;&#9;&#9; &#9;&#9;} &#9;&#9; &#9;&#9;override func viewDidAppear(_ animated: Bool) { &#9;&#9;&#9;&#9;super.viewDidAppear(animated) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;print("Initial View Controller : ViewDidAppear") &#9;&#9;&#9;&#9;if UserDefaults.standard.object(forKey: "loginTokenDict") == nil { &#9;&#9;&#9;&#9;&#9;&#9;print("go to login") &#9;&#9;&#9;&#9;&#9;&#9;self.performSegue(withIdentifier: "loginSegue", sender: self) &#9;&#9;&#9;&#9;} else { &#9;&#9;&#9;&#9;&#9;&#9;print("go to dashboard") &#9;&#9;&#9;&#9;&#9;&#9;self.performSegue(withIdentifier: "viewDashBoard", sender: self) &#9;&#9;&#9;&#9;} &#9;&#9;} }
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to choose a character
What is your problem ? Is it how to present the list of characters ? If so, you have several solutions: use a segmented control (may be the simplest) insert directly in the view switches to select the character you want. create an alert with a button for each selection Please explain precisely Note: I would not use Character here which is a reserved type.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Help with idea/formation of app creation.
Hope I understand well,. So you want to propose user a list of drills to perform during its work out ? If so, it is feasible, if you have defined the logic of a "good" workout. You just have to pick (randomly ? logivally ?) as many types of drills according to the frequency you want. What is your problem precisely ?
Mar ’21
Reply to App store release crashing
What do you mean line 40 : NEVER GETTING TO API Do you go to line 45 instead ? In that case, have you checked the value of statusCode ? If you go line 45, what is self.promptTouchOrFaceID() Are you sure it does not access UI API and thus should run in main thread ?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to choose a character
Problem is not with character but Character. You could simply use Characters for character in Characters { print("\(character.charactersName), \(character.weapon), \(character.lifePoint)") } Could you show how youn definer the Character struct ?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to initialization error when trying to segue or instantiate to vc
Before I connected the CheckoutViewController to storyboards What do you mean ? That app did "work" before you did any connection ? What did you connect ? The IBOutlets ? The IBActions ? What crash message do you get ? Please show the complete code for the ViewController, with its IBOutlet declarations and all the code. It's not very good to have super.init on line 13, in the middle. Move it at the beginnng of init()
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Is it possible or not to come back to the current view after the user comes to the app again?( Once the app was destroyed )
If destroyed means closed, yes: If you save the last visited view in userSettings, you can get it back when you reopen and go to this view automatically. But if destroyed means removed from the iPhone and you have to download again, no. You loose everything. Unless you save a user context on a server, but that adds useless complexity.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21