Build an xcode text to speech application - ios

I am building a project that involves creating a mobile app in xcode. The idea is that a user can click a button/menu item and the app will read out what is on the button/menu item. Essentially it is an app for those who have difficulty with their eyesight and require confirmation on what has been pressed.
For example if the button/menu item said "hello there" on it by clicking the button/menu item it would read out "hello there" so the user could hear it.
As mentioned it is been built using xcode and I am aware of AVSpeechSynthesizer. All i can find online are tutorials that either translate your speech or require the user to type in what they want reading out.
Any tips on how this could be achieved?

iOS applications automatically read many screen elements when VoiceOver is enabled on your device. If you have custom elements on screen that you want it to read in a particular way, you'll need to investigate the usage of UIAccessibility.

AVSpeechSynthesizer can certainly read out whatever text you want it to, the user doesn't need to type anything in. Share some code that uses it and we can help you out.

No need for you to reinvent that wheel iOS already supports this behavior look into UIAccessibility.
For example to make a button conform to UIAccessibility you need just one line of code.
[button setAccessibilityLabel:NSLocalizedString(#"Your Name Here", nil)];
and to set a hint
[button setAccessibilityHint:NSLocalizedString(#"Your Hint Here", nil)];
hope that helps -- seems like you can take today off ;)
and if you are not sure how to use Accessibility on your device visit this link -- http://support.apple.com/en-us/HT5018

Related

How to modify a ShareViewController so that choosing an app in the share sheet results in saving media and launching the selected app?

The ability to import media files from various apps (like Photos, Files, WhatsApp) to an app I am building (referred to as "My App" from hereon) using a share button is what I am seeking to achieve.
The user interaction process should be as follows:
Step 1: Select media file from any app
Step 2: tap share button which should list "My App" among others
So far, I have been able to get my app listed on the sharesheet sorted based on this article. I have also looked at this post that makes use of SLComposeServiceViewController which caters to the more of a social media like popup from a sharesheet. Neither of these have helped reach a solution.
However, I am unable to achieve my desired outcome from user action of selecting "My App" from the sharesheet, which is:
a. have selected media copied into a directory accessible to "My App"; and
b. launch "My App" in the View that shows the contents of this directory. (As the capitalisation of View demonstrates, I am writing "My App" in SwiftUI.)
Working through the aforementioned tutorial, I was unable to figure out how to achieve the described outcome; this might have to with my quite limited experience of to manipulating UIViewControllers, which I have managed to avoid so far with SwiftUI.
Any guidance on this matter would be highly appreciated.
For those looking for a pure SwiftUI and code-only approach way of solving the problem of importing media/data into your app, the most straightforward solution I found was to use .fileImporter in a View. An excellent explanation and example code is available here. The only drawback is that your app is not on the sharesheet but that is okay, in my opinion/use case.
The beauty of this solution is that:
It is code only and doesn't require you to mess around with the info.plist file to define the UTI as per this tutorial
better yet, you do not deal with the Share Extensions and the corresponding ShareViewController, which is no fun to figure out for a purely SwiftUI-based developer.

Prevent Autocorretion of a Word in Swift

My client's chat app is autocorrected whenever it is mentioned in UITextViews within the app.
So if it's called XYZ (just making this up) whenever users type XYZ in a UITextView in the app, it tries to autocorrect it.
I know this is a small/petty thing, but he feels like it's embarrassing to see the app's name try to be changed for users of it, if that makes sense.
Any chance I could have that specific word ignored for the UITextView inside the actual app? Or does this require modifying the user's SwiftKey or something on a per-user basis to avoid?
Thanks for any help / direction anyone can provide!
A very well documented tutorial about UITextChecker given by NSHipster blog.
You should focus on the Learning a New word Section of the blog, which should give you answer
Just for the sake if people don't want to jump around links
Let’s assume that you want your users to be able to type "xyz"
exactly. Let your app know that by telling it to learn the word, using
the UITextChecker.learnWord(_:) class method:
let someNewWordTheAppNeedsToLearn = "xyz"
UITextChecker.learnWord(someNewWordTheAppNeedsToLearn)
I believe you can create a wrapper class exclusively for making app learn words and call it in your app delegate.
Apple Documentation
You can use UITextChecker in the root view controller's viewDidLoad()
UITextChecker.learnWord("xyz")

How do I export text from iOS Notes app to my app?

I know this is possible and is something many big apps do, but I can't figure out among UTIs, extensions, UIActivityTypes, etc. which spell I need to use for this in particular. I'm trying to add my app to the list of apps that appear when you hit the export button in the Notes app on iOS because I want to be able to take a bunch of text inside a note and repeatedly and safely send it into my app.
I want my app to appear in this list, exporting directly from Notes. There appear to be duplicates of this question that are very old claiming that "exporting from Notes app is not possible for third party apps", but I think they're either now wrong or answering a different question because as you can see in the above screenshot, Messenger is plainly able to do this.
It does not look like registering UTIs gets this done for me. I went ahead and registered my app to all sorts of UTIs, but all that happens is my app ends up in popups like this one, which appears when trying to open a txt file, which is not what I'm looking for. Unless there is some other UTI that does not conform to public.data or public.content which I need to be using, in which case I'd be happy to hear it.
I used one of my allotted support requests to ask Apple, and after some time and back and forth I was able to get my answer! Here is what they said:
Your project is missing a Share app extension. Start by reviewing the
App Extension Programming Guide:
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/index.html#//apple_ref/doc/uid/TP40014214-CH20-SW1
Information specific to the Share extension point:
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1
You don’t need to register the text content type in your
CFBundleDocumentTypes. as you’ve done in your sample. However, you
will need to provide an activation rule for the extension point, such
as the one shown in this section of the document (the section titled
Declaring Supported Data Types for a Share or Action Extension):
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1
See specifically the predicate example that activates the extension if
an attachment with the com.adobe.pdf UTI is present. You will need to
do something similar, to cover the UTIs for content you would like
your share extension to consume. As a starting point, you can consume
text with the public.text UTI. For more common UTIs, please see this
document:
https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1
I also found the bits about providing an activation rule to be super confusing, and this answer helped that: How do I set NSExtensionActivationRule predicates?

iOS 8 Today Extension: Is it possible to add editable text field?

I am trying to create a simple Today Extension. I was able to add a label wherein the value can be updated via the main app. Now, I am exploring the possibility to update the value in main app via the extension. However, when I tried to add a textfield, I cannot input anything.
Is this a limitation of the extension? If not, can you please guide me how to accomplish this? Thank you very much!
Unfortunately, it is a limitation.
It says in Apple's extension programming guide:
Because user interaction with Today widgets is quick and limited, you should design a simple, streamlined UI that highlights the information users are interested in. In general, it’s a good idea to limit the number of interactive items in a widget. In particular, note that iOS widgets don’t support keyboard entry.
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Today.html#//apple_ref/doc/uid/TP40014214-CH11-SW1

How to add icons and more text inside Settings.bundle. Get more options

I am learning iOS development and I have some questions to ask you in my first post.
To learn iOS I do an stupid application which have Settings.bundle. I want to put small images or icons inside it but I can't.
I also write to the right of the PSChildPaneSpecifier the value of a PSToggleSwitchSpecifier
Apple does it, see the image:
I search in NSUserDefaults Class Reference but I didn't find anything about this. Maybe it is impossible and only Apple can do.
You're right, it's something only Apple can do. Third-party apps are limited in what they can achieve in the settings bundle. The only icon you can have is the app icon on the first page, and the only information on the right hand side will be string values - see here for details.
Without being jailbroken you cannot achieve this, Apple simply won't allow it and does not offer a way to do this.

Resources