Post

Replies

Boosts

Views

Activity

Reply to How to prevent Critical Alerts from cutting out a call
Critical alerts are just done for that: have precedence over everything else. So it is normal it interrupts Teams audio. But surprising that you are forced to relaunch Teams to get audio back. What your app's users could do is turn off critical alerts for your app during the time of a Teams meeting for instance. But if you got an entitlement for critical alert, there must be some serious reason (and thus risky to stop them). May read this: https ://www.howtogeek. com/412925/what-are-critical-alerts-on-iphone-and-ipad-and-how-do-i-enable-them/
Mar ’21
Reply to LaunchScreen Storyboard with NS Vue + xCode
Im wondering if it's impossible to make the launchscreen storyboard showing on several simulators and devices these days I don't understand the question. What do you want to do ? That's not clear. In Xcode: Launchscreen shows on any simulator you select in Xcode as the active Scheme. What is it you cannot do ? In VS, that's a question for VS.
Apr ’21
Reply to College Documents for the Challenge
I think it is explained here, with many other details: https://developer.apple.com/wwdc21/swift-student-challenge/ Provide school information. Upload your most recent class schedule or other most recent proof of enrollment (PDF, PNG, or JPG) and the contact information for your educational supervisor. Documentation is accepted in all languages. Good luck. And if that answers your question, don't forget to close the thread.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Math Problem, entering an answer
When you post code, you should use Paste and Match Style to avoid all the extra lines that make reading difficult. Your problem seems to be here: @IBAction func btncheckAnswer(_ sender: Any) { if (ranA) + (ranB) == answer { correctAnswer() } else { wrongAnswer() } } Where do you get answer ? With this code it is always 0 Line 34 should probably be the other way: answer = Int(youAnswer.text) ?? 0 Note: no need to enclose randA and randB in parentheses. Reformatted code: import AVFoundation import Foundation class YouSolveIt: UIViewController { @IBOutlet var topProblem: UILabel! @IBOutlet var botProblem: UILabel! @IBOutlet var youAnswer: UITextField! @IBOutlet var actualCard: UIImageView! let speakit = AVSpeechSynthesizer() var problem1 = Int(0) var problem2 = Int(0) var answer = 0 var ranA = 0 var ranB = 0 override func viewDidLoad() { super.viewDidLoad() // Load Flash Card image: actualCard.image = UIImage(named: "FlashCard") solveitproblem() } func solveitproblem() { let ranA = Int(arc4random_uniform(UInt32(9))) let ranB = Int(arc4random_uniform(UInt32(9))) topProblem.text = String(ranA) botProblem.text = String(ranB) youAnswer.text = String(answer) let speakProblem = AVSpeechUtterance(string: "What is \(topProblem.text! + ", plus ," + botProblem.text!)") speakit.speak(speakProblem) } @IBAction func btncheckAnswer(_ sender: Any) { if (ranA) + (ranB) == answer { correctAnswer() } else { wrongAnswer() } } func correctAnswer() { let right = [1,2,3,4,5] let randomIndex = Int(arc4random_uniform(UInt32(right.count))) switch(randomIndex) { case 1: let speakRight = AVSpeechUtterance(string: "That is correct") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() case 2: let speakRight = AVSpeechUtterance(string: "You're right!") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() case 3: let speakRight = AVSpeechUtterance(string: "Correct! Let's try.") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() case 4: let speakRight = AVSpeechUtterance(string: "You are right! Next Try.") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() case 5: let speakRight = AVSpeechUtterance(string: "Great answer!") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() default: let speakRight = AVSpeechUtterance(string: "Very good!") speakit.speak(speakRight) youAnswer.text = "" solveitproblem() } } func wrongAnswer() { let wrong = [1,2,3,4,5] let randomIndex = Int(arc4random_uniform(UInt32(wrong.count))) switch(randomIndex) { case 1: let speakRight = AVSpeechUtterance(string: "That is wrong") speakit.speak(speakRight) case 2: let speakRight = AVSpeechUtterance(string: "You're wrong, please try again.") speakit.speak(speakRight) case 3: let speakRight = AVSpeechUtterance(string: "No, that's not it. Please try again.") speakit.speak(speakRight) case 4: let speakRight = AVSpeechUtterance(string: "No") speakit.speak(speakRight) default: let speakRight = AVSpeechUtterance(string: "I'm sorry, no. Please try again.") speakit.speak(speakRight) } } }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Notification Center Help
@ ZoneX You say: Okay so your solution dismisses my HdVC but when it goes to FaVC it doesn't seem to have the data. I just see a white screen which means my transferred item is nil still. What is the data you try to transfer ? Which var content ? If it is currentFav, then I would : DispatchQueue.main.async { // pour update UI if let passDataVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FavViewID") as? FavouritesVC { passDataVC.currentFav = item // if this is what you want to pass self.present(passDataVC, animated: true, completion: nil) } Please, when you answer and there are several posts, please remind who you are replying to.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Control the volume up and down button
AFAIK, it is forbidden to change the behaviour of those buttons. They are reserved for sound volume. It would be very misleading for user to have the buttons not reacting as they should. Of course you could detect volume change and use the volume information for your purpose, but you would be limited to the min and max volume values. So, as a conclusion, don't try to do that. May read discussion in this old thread: https://developer.apple.com/forums/thread/107241
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Notification Center Help
I miss something in the logic. The notification is sent by FavoritesVC. But where is currentFav initialised ? And why don't you simply append in HockeyDetailVC ? In your IBAction @IBAction func addToFav(_ sender: Any) { let alert = UIAlertController(title: "Favourite Added 💙", message: "\(name.text ?? "") is added to favourites", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)) self.present(alert, animated: true, completion: nil) print("Favourite button Pressed") let passDataVC = FavouritesVC() /* I think passDataVC is supposed to be different because I use storyboard but I don't know what else it's supposed to be. */ self.present(passDataVC, animated: true, completion:nil) } Line 5 and next will be executed before you tap OK. Is it what you want ? In addition, you will probably have an error like: 2021-03-31 15:20:44.949122+0200 simpleTest[54293:11989110] [Presentation] Attempt to present xxxx.FavouritesVC: 0x7fbfd14534c0 on xxxx.HockeyDetailVC: 0x7fbfd3014000 (from xxxx.HockeyDetailVC: 0x7fbfd3014000) which is already presenting UIAlertController: 0x7fbfd1877a00. I changed as follows to make it work (call the next VC in the completion of button). FavViewID is the ID of FavouritesVC @IBAction func addToFav(_ sender: UIButton) {      let alert = UIAlertController(title: "Favourite Added 💙", message: "\(name.text ?? "") is added to favourites", preferredStyle: .alert) alert.addAction(UIAlertAction( title: "OK", style: UIAlertAction.Style.default, handler: { _ in DispatchQueue.main.async { // pour update UI if let passDataVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FavViewID") as? FavouritesVC { self.present(passDataVC, animated: true, completion: nil) } } })) self.present(alert, animated: true, completion: { print("Favourite button Pressed") } ) }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21