NSAttributedKey UIAccessibilitySpeechAttributeQueueAnnouncement - ios

I would liked to post a queued announcement
I tried using UIAccessibilitySpeechAttributeQueueAnnouncement but I have trouble converting it into an NSAttributedStringKey
Code:
let queueAnnouncementKey = NSAttributedStringKey(rawValue: UIAccessibilitySpeechAttributeQueueAnnouncement)
let announcementString = NSAttributedString(string: "something",
attributes: [queueAnnouncementKey : NSNumber(booleanLiteral: true)])
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcementString)
Problem:
The announcement is not queued, if there is an on going announcement at that moment, it ignores my announcement
Possible Cause:
I think something the way I create NSAttributedString is wrong
I think the NSAttributedString has changed from the time this presentation was made, so needed to use rawValue.
May be it is because it is not the correct raw value and that is causing it not to work.
Refer:
https://developer.apple.com/videos/play/wwdc2017-215/?time=1627
https://devstreaming-cdn.apple.com/videos/wwdc/2017/215avg3cuo2bu/215/215_whats_new_in_accessibility.pdf?dl=1

Don't worry, your code is correct with your annoucementString.
However, you should read this answer to understand the use cases why it doesn't work as you want because the system takes over when needs be and all the queued announcements are removed then.

Related

Firebase updateChildValues in iOS, what's more optimized?

I work on an iPhone app (Swift 4), I do some updates on my database at few nodes at the same time.
Both following methods work but I'm wondering what's the most "clean" one ?
Way 1 :
let idNotification = BaseViewController.database.child("notifications").childByAutoId().key
BaseViewController.database.child("notifications").child(idNotification).updateChildValues(["content" : "some content"])
BaseViewController.database.child("users").child(userID).child("notifications").updateChildValues(["something" : true])
Way 2 :
let idNotification = BaseViewController.database.child("notifications").childByAutoId().key
let createNotif = ["content" : "some content"]
let notifToUser = ["something" : true]
BaseViewController.database.updateChildValues(["/notifications/\(idNotification)" : createNotif, "/users/\(userID)/notifications" : notifToUser])
And if that makes any difference in case of crash ? With the first one, if one of the two update request fail the other one will not be impacted. What happens with method 2 if there is a fail just for one of the two ?
Thanks !
The first snippet send multiple write operations to the database (one for each call to updateChildValues). The second snippet sends exactly one write operation.
Both are completely valid, and either could be what you want. For example, if there's no relation between the two updates, then it makes sense to send them separately. But if the updates are related, it makes more sense to send them in one go, since that allows the security rules of your database to allow/reject them as one write operation.

Unrecognized Selector sent to instance, not view related

I have an annoying problem in my iOS app. Suddenly, when I start my view controller with a table view inside, I get the following error:
Unrecognized selector sent to instance
After googling a lot about this problem, it seems like it is usually related to a falsely connected IBOutlet/IBAction or generally something with the UI.
But I could exclude these causes, since I removed all IBOutlets and the problem still persisted.
After long hours, I found the solution for this and wanted to share it in a Q&A fashion, in case someone else is having a hard time on this.
The problem was this line of code:
outletCommentShowMore.attributedText = NSAttributedString(
string: isExpanded ? "show less" : "show more",
attributes: [
NSAttributedStringKey.foregroundColor : Theme.primaryTextColor,
NSAttributedStringKey.underlineStyle : NSUnderlineStyle.styleSingle
]
)
The error was that I passed an enum (NSUnderline.styleSingle) directly into the attributes dictionary of an NSAttributedString. But it has to be the rawValue of the enum!
So after changing this to NSUnderline.styleSingle.rawValue my error disappeared
Hope this helps someone

How many maximum printings can UIPrintInteractionController (Swift) execute?

How many maximum printings can UIPrintInteractionController (Swift) execute?
I'm currently doing AirPrint for a project.
Wondering how to do stress tests of printing in bulk in use of Printer Simulator.
Is there a delegate of something like printInteractionControllerIsPrintingJob?
How to debug a number of printing waiting in queue?
Is there any way to customise the alert view of printing?
Cheers,
From the documentation :
1- var printingItems: [Any]? { get set }
Takes an array of printing-ready objects ( NSURL, NSData, UIImage, or ALAsset). The documentation doesn't cite any limit so we assume the limit would be the value of unsigned int in your architecture.
2- There are 2 delegate methods for the beginning and end of printing :
Start and End of a Print Job
func printInteractionControllerWillStartJob(UIPrintInteractionController)
//Tells the delegate that the print job is about to start.
func printInteractionControllerDidFinishJob(UIPrintInteractionController)
//Tells the delegate that the print job has ended.
You can use those to get the IsPrinting status. (between first and second).
3- The documentation doesn't offer any delegate method to get the waiting in queue
4- You can customise the alert using :
printInfo UIPrintInfo: The aforementioned print job configuration.
printPaper UIPrintPaper: A simple type that describes the physical and printable size of a paper type; except for specialized applications, this will be handled for you by UIKit.
showsNumberOfCopies Bool: When true, lets the user choose the number of copies.
showsPageRange Bool: When true, lets the user choose a sub-range from the printed material. This only makes sense with multi-page content—it’s turned off by default for images.
showsPaperSelectionForLoadedPapers Bool: When this is true and the selected printer has multiple paper options, the UI will let the user choose which paper to print on.
For some detailed explanation about printing using Swift, please refer to the following link:
UIPrint​Interaction​Controller - Written by Nate Cook
If this response was helpful and has what you needed, please don't forget to validate it :).
Good luck with your app.

NSFileManager leads to SourceKit Service Terminated

It's totally confusing on using this line
var docContents : NSArray! = NSFileManager.defaultManager().contentsOfDirectoryAtPath(archieveDirectoryPath,error:
&err)
I get the alert like SourceKit Service Terminated Editor Functionality temporary limited continuously, and gone swift coding style. But When I comment this line, all are disappeared.
Any one experienced this or is this a common error?
Note: I've tried this post's answer, But won't work. Just comment that line, it gets work. But I need that line. I'm using Xcode-6-beta-2
Finally fixed by below code. I think, it may common error. Just replace ! with ? symbol.
var docContents : NSArray? = NSFileManager.defaultManager().contentsOfDirectoryAtPath(archieveDirectoryPath,error:
&err)
But I didn't see any docs related how this happen. If anybody know, let me know. I think, this may temporary workaround.

Unable to get UIAutomation iOS UILabel value

I am trying to get the value "HELLO" of the UILabel shown in the iPad simulator.
I have enabled accessibility and have set the label as "Label Access".
But when I call target.logElementTree(), both the name and value are set to "LabelAccess" and as far as the apple docs say, the value field should contain the string that is set (in this case "Hello").
Does anybody know a fix for this?
PS: I am using the latest iOS SDK and Xcode.
Apple Stack Exchange
I think you encountered a UIAutomation bug that exists since forever.
Easiest way to get around this bug is to set the accessibilityValue to your text in code.
Something like this.
NSString *valueString = [NSString stringWithFormat:#"%d", value];
self.label.text = valueString;
self.label.accessibilityValue = valueString;
Helps those people that use Voice Over too ;-)
thanks for the workaround. Doesn't look like this bug has been fixed.
Came across this while writing Appium test for the iOS app. The element found by the driver somehow only contains accessibilityLabel and accessibilityIdentifier but not the actual text that's shown on the screen.
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value=<accessibilityLabel> name=<accessibilityIdentifier> label=<accessibilityLabel> .../>
Has someone found if this issue has been logged with apple?
EDIT: Refer to this answer and the comment underneath. https://stackoverflow.com/a/11411803/4725937
Basically need to use [accessibilityValue]: https://developer.apple.com/documentation/uikit/uiaccessibilityelement/1619583-accessibilityvalue for accessible components for the display text to show up as XCUIElementTypeStaticText.value in the page source.
For eg:
someUILabel.accessibiityLabel = "This is used for voice-over"
someUILabel.accessibilityValue = "This is displayed text"

Resources