Post

Replies

Boosts

Views

Activity

Reply to Need notification in code, if user change View
What you should do, in the VC : Declare at class level:     var synthesizer : AVSpeechSynthesizer? Everywhere you need to speak, you set the var : // Avoid superposition of speakers if synthesizer != nil { synthesizer!.stopSpeaking(at: .immediate) synthesizer = nil } let newSynthe = whatToSpeak.speakIt() synthesizer = newSynthe And close when disappear: override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) if synthesizer != nil { synthesizer!.stopSpeaking(at: .immediate) synthesizer = nil } } Used, works well.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Picker with SegmentedPickerStyle and Image
Well, you did not say what the exact problem was. I thought you did not see the image, in fact it is not displayed properly. In fact it appears that scaleToFit does nothing ! https://stackoverflow.com/questions/59635519/swiftui-picker-segmentedstyle-image-bad-display Should file a bug report. Note: that is the same problem than in UIKit TabBar icons. You have to manually size the image before using. Thanks to note the FB reference if you file a bug report. And don't forget to close the thread.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Closure definition mismatch
See this: https://developer.apple.com/app-store/submissions/  https://developer.apple.com/ios/submit/ says: Starting April, 2020, all apps submitted to the App Store will need to be built with Xcode 11. Xcode 11 requires macOS Mojave 10.14.3 or later. Starting April 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK. And more here: https://stackoverflow.com/questions/41891165/minimum-xcode-version-to-upload-to-app-store
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Xcode and iOS render SVG gradient upside down
Is it a problem new to iOS 14.4 and/or Xcode 12.4 ? I did not analyse in depth you gradient definition. But you use a transform, have you check it is not what causes the inversion ? I also remember there are some cases (don't remember which) where the coordinate system in iOS API is reversed (y-negative usually, but in some case y-positive as on MacOS). Could it be the reason ? See some partly related discussion here: https://stackoverflow.com/questions/41644590/why-did-apple-flip-their-unit-circle-for-uibezierpath
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Need Assistance with sending attachments for MFMessageComposeViewController
Thanks for the code. But, please, edit it properly to avoid all these empty lines which make it impossible to read. I did some formatting: import UIKit import MessageUI class FourthScreenViewController: UIViewController, MFMessageComposeViewControllerDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate { func numberOfComponents(in pickerView: UIPickerView) - Int { return 1 } func pickerView( _ pickerView: UIPickerView, numberOfRowsInComponent component: Int) - Int { if currentTxtFldTag == 10 { return pickOption.count } else { return ageOption.count } } func pickerView( _ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) - String? { if currentTxtFldTag == 10 { return pickOption[row] } else { return ageOption[row] } } func pickerView( _ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { if currentTxtFldTag == 10 { notesField.text = pickOption[row] self.view.endEditing(true) } else { TimeOfDay.text = ageOption[row] self.view.endEditing(true) } } func textFieldShouldBeginEditing(_ textField: UITextField) - Bool { if textField.tag == 10 // WEIGHT OPTION { currentTxtFldTag = 10 } else // AGE OPTION { currentTxtFldTag = 20 } pickerView.reloadAllComponents() return true } let ageOption = [String](arrayLiteral: "I need a free quote on site.", "I may have more than what's shown.", "I need scheduling/pricing for ONLY what's shown.", "I have a question not offered here.") let pickOption = [String](arrayLiteral: "Morning", "Mid-Morning", "Mid-Day", "Afternoon") let pickerView = UIPickerView() var currentTxtFldTag : Int = 10 func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) { self.dismiss(animated: true, completion: nil) } @IBOutlet weak var FreshImage1: UIImageView! var newImage: UIImage! @IBOutlet weak var FreshImage2: UIImageView! var newImage2: UIImage! @IBOutlet weak var FreshImage3: UIImageView! var newImage3: UIImage! @IBOutlet weak var nameField: UITextField! @IBOutlet weak var addressField: UITextField! @IBOutlet weak var emailField: UITextField! @IBOutlet weak var notesField: UITextField! @IBOutlet weak var TimeOfDay: UITextField! @IBAction func SubmitNow(_ sender: Any) { print("Submission Button Has Been Pressed") if (MFMessageComposeViewController.canSendText()) && (MFMessageComposeViewController.canSendAttachments()) { let controller = MFMessageComposeViewController() controller.body = "Name: \(nameField.text!) \n\nAddress: \(addressField.text!) \n\nEmail: \(emailField.text!) \n\nTime of Day: \(notesField.text!) \n\nNotes: \(TimeOfDay.text!)" controller.recipients = [" our phone number "] controller.messageComposeDelegate = self let image1 = FreshImage1.image! let dataImage1 = image1.jpegData(compressionQuality: 100) guard dataImage1 != nil else { return } controller.addAttachmentData(dataImage1!, typeIdentifier: "image/jpeg", filename: "Image1.jpeg") self.present(controller, animated: true, completion: nil) let image2 = FreshImage2.image! let dataImage2 = image2.jpegData(compressionQuality: 100) guard dataImage2 != nil else { return } controller.addAttachmentData(dataImage2!, typeIdentifier: "image/jpeg", filename: "Image2.jpeg") self.present(controller, animated: true, completion: nil) let image3 = FreshImage3.image! let dataImage3 = image3.jpegData(compressionQuality: 100) guard dataImage3 != nil else { return } controller.addAttachmentData(dataImage3!, typeIdentifier: "image/jpeg", filename: "Image3.jpeg") self.present(controller, animated: true, completion: nil) } } @IBAction func HomeButton(_ sender: Any) { self.performSegue(withIdentifier: "GoHome3", sender: self) } @IBAction func BackButton2(_ sender: Any) { self.performSegue(withIdentifier: "Back1", sender: self) } override func viewDidLoad() { super.viewDidLoad() FreshImage1.image = newImage FreshImage2.image = newImage2 FreshImage3.image = newImage3 pickerView.delegate = self pickerView.dataSource = self notesField.tag = 10 TimeOfDay.tag = 20 notesField.delegate = self TimeOfDay.delegate = self notesField.inputView = pickerView TimeOfDay.inputView = pickerView overrideUserInterfaceStyle = .light // Do any additional setup after loading the view. } @IBAction func dismissKeyboard(_ sender: Any) { self.resignFirstResponder() } } To make code more robust, replace line 98 instructions as: let image1 = FreshImage1.image! let dataImage1 = image1.jpegData(compressionQuality: 100) by if let image1 = FreshImage1.image { // If that succeeds, that will unwrap let dataImage1 = image1.jpegData(compressionQuality: 100) } else { return } Do the same on lines 106 and 114. Replace line 94 controller.body = "Name: \(nameField.text!) \n\nAddress: \(addressField.text!) \n\nEmail: \(emailField.text!) \n\nTime of Day: \(notesField.text!) \n\nNotes: \(TimeOfDay.text!)" by let name = nameField.text ?? "" let address = addressField.text ?? "" let email = emailField.text ?? "" let notes = notesField.text ?? "" let time = TimeOfDay.text ?? "" controller.body = "Name: \(name) \n\nAddress: \(address) \n\nEmail: \(email) \n\nTime of Day: \(time) \n\nNotes: \(notes)"
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Position UIButton title below image
Are you sure they are using SFSymbols in the SO post ? SFSymbols are not png images, they behave differently. So either get a png version of the symbol of create button + label. You could subclass a UIView (in fact UIControl) to cope with the tinting on selection.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21