Thanks you for the reply. I this case the user knows they are typing in a % value. So wouldn't they be expecting to need to enter a value from 1 to 100?
Post
Replies
Boosts
Views
Activity
Thanks PBK,I tried at least 6 ways of doing this but this was the only one the worked.I had to figure out a little more about NotificationCenter than I originally knew but I got it working.Even figured out how to pass data to the parrent VC in the Notification// In parrent
static let notificationName = Notification.Name("ClosingChild")
override func viewDidLoad()
{
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(returnFromPopup), name: Tally_VC.notificationName, object: nil)
}// End of viewDidLoad
@objc func returnFromPopup(notification: Notification)
{
if let data = notification.userInfo?["data"] as? Bool
{
if data
{
self.populateTheData()
self.tableView.reloadData()
} else {
//print("It didn't run")
}
}
}
// In child
var pass_Popup: Bool = false
override func viewDidDisappear(_ animated: Bool)
{
super.viewDidDisappear(animated)
setThe_Pass_Bool()
NotificationCenter.default.post(name: Tally_VC.notificationName, object: nil, userInfo: ["data": pass_Popup])
}
Hi Claude,Thanks you for checking into this.I also tested the app on my iPhone XS MAX and my iPhone 6s and you are correct. It does work as expected on the physical devices. I apologize for not following through on testing on the device. I guess I just got wrapped around the axle when it didn't work on the sim.I'm in the final stages of finishing a series of 8 apps and this through a monkey wrench into the works.I do not have an iPad to test on. I'll try to find someone with an iPad to test it. Until then I'm not comfortable releasing any apps using this code.Thank you,Tom
Thanks, I'll try using the attributedPlaceholder.
Thanks for the reply,Nothing happens except the warning message. I even tried setting the switch action from "value changed" to "touch up inside", got the same warning. Looks to me like a glich with UISwitch.
That worked!class MyNavigationController: UINavigationController
{
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var preferredStatusBarStyle: UIStatusBarStyle
{
return Theme.current.barStyle
}
}
So far I am still trying to figure this out. My app has 51 views and one navigation controller linked to the first view. I tried updating the cocoa pods. I've looked at everywhere in my app that I set the preferredStatusBarStyle. There doesn't seem to be a correlation. It still works fine on Xcode 11.3.1 but preferredStatusBarStyle doesn't fire on 11.4 or 11.4.1I have a theme protocol and three themes following it (lite, grey and dark). The themes set the preferredStatusBarStyle to .default or .lightContentThis is from the LiteThemevar barStyle: UIStatusBarStyle = .defaultThis is in every viewController override var preferredStatusBarStyle: UIStatusBarStyle
{
return Theme.current.barStyle
}
So I created a test app in xcode 11.4.1Ran it and the print statement fired.Then I ran it in xcode 13.3.1The print statement fired.Then I embedded the view in a navigationColtrollerThen I ran it in xcode 13.3.1The print statement did not fire.Then I ran it in xcode 13.4.1The print statement did not fire.Then I deleted navigationColtrollerThen I ran it in xcode 13.3.1The print statement fired.Then I ran it in xcode 13.4.1The print statement fired.It's the same in the sim or device.override var preferredStatusBarStyle: UIStatusBarStyle
{
print("preferredStatusBarStyle fired")
return .lightContent
}
If I load the same app into xcode 11.3.1, iOS 13.3.1, the print statment runs. This is on either my iPhone 6s or iPhone XSMax or the sim. I haven't tried to test this on anything but my app. I'll create a quick test app and see.
Yes. If I uncomment the print statment it does not print in iOS 13.4 and 13.4.1If I load the same app into xcode 11.3.1, iOS 13.3.1, the print statment runs. This is on either my iPhone 6s or iPhone XSMax or the sim.
Here's what I ended up doing. It dosen't give a cancel button but it does show a back button, which in my case works ok.let editBtn = UIAlertAction(title: NSLocalizedString("EditContact_String", comment: ""), style: .default) { (editAction) in
self.requestAccess { (accessGranted) in
let store = CNContactStore()
var vc = CNContactViewController()
do {
let descriptor = CNContactViewController.descriptorForRequiredKeys()
let editContact = try store.unifiedContact(withIdentifier: self.oldContactID, keysToFetch: [descriptor])
vc = CNContactViewController(for: editContact)
} catch {
print("Getting contact to edit failed: \(error)")
}
vc.delegate = self // delegate for CNContactViewControllerDelegate
// vc.allowsActions = false
// vc.allowsEditing = true
// vc.title = "Edit Contact"
self.navigationController?.isNavigationBarHidden = false
self.navigationController?.navigationItem.hidesBackButton = false
self.navigationController?.pushViewController(vc, animated: true)
// DispatchQueue.main.async {
// self.present(UINavigationController(rootViewController: vc), animated: true)
// }
}
}
Thanks. I appreciate that.Seems strange that in a select a contact CNContactPickerViewController() and a create a contact CNContactViewController(forNewContact: openContact) both show cancel buttons. And in the contacts app, if you manually edit a contact, it shows a back button. It's odd that it doesn't automatically show up on the edit a contact CNContactViewController(for: editContact).
I have a simple follow-on question. When the CNContactViewController opens it has a rightBarButtonItem set to Edit. How do I add a rightBarButtonItem to Cancel ie. dismiss the CNContactViewController?
Thanks again, OOPer.Just in case others have he same requirment, here's the code I ended up with.let theAlert = UIAlertController(title: NSLocalizedString("ContactNoAddress_String", comment: ""), message: nil, preferredStyle: .alert)
let cancelBtn = UIAlertAction(title: NSLocalizedString("OK_String", comment: ""), style: .cancel) { (cancelAction) in
self.populateThePrintFld()
}
let editBtn = UIAlertAction(title: NSLocalizedString("EditContact_String", comment: ""), style: .default) { (editAction) in
self.requestAccess { (accessGranted) in
let store = CNContactStore()
var vc = CNContactViewController()
do {
let descriptor = CNContactViewController.descriptorForRequiredKeys()
let editContact = try store.unifiedContact(withIdentifier: self.theContactID, keysToFetch: [descriptor])
vc = CNContactViewController(for: editContact)
} catch {
print("Getting contact to edit failed: \(error)")
}
vc.allowsEditing = true
vc.delegate = self // delegate for CNContactViewControllerDelegate
DispatchQueue.main.async {
self.present(UINavigationController(rootViewController: vc), animated: true)
}
}
}
theAlert.addAction(cancelBtn)
theAlert.addAction(editBtn)
present(theAlert, animated: true)extension QuotePreview_VC: CNContactViewControllerDelegate
{
func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?)
{
// Edit an existing contact with ID theContactID
populateThePrintFld()
self.dismiss(animated: true, completion: nil)
}
}
Thank you very much! I've been struggling with this for over a week. After I posted this question I was thinking whether I should use the address ID or the address label to perform this operation. My thought is that if the user gets a new phone and loads the app then the address IDs would be different and that might cause a problem. However, the address label would be the same. Am I over thinking this?