How to get text content from iOS screen? - ios

How to get the text content of screen? Both from a WebView and a Native App.
For example, from the following image, I would like to get/extract/retrieve the title and the first two paragraphs.
On Android this is possible using the accessibility tools. But so far I haven't found how to do something like that on iOS.
I would like to know how to do this natively using Swift / Xcode. But if is possible with EXPO or React Native it would also help a lot. Thank you.

I think that what you are asking is the accessibility identifier.
Under the identity inspector you can find the Accessibility section and there you have a text field for an identifier.
Alternatively you can set this via code
for example:
submitButton.accessibilityIdentifier = "submitButton"

Related

How to use Swift Playgrounds-style code input keyboard/text field in normal text view?

I'm making an iPad app that lets me write swift code into a text box and save it to a document. It doesn't do any compilation or any complicated stuff like that, so I'm just looking for a way to format the code correctly in the text box (ex: code autocomplete, autoindent if possible, and maybe syntax highlighting). In short, I'd like my app's text field and keyboard to look similar to those of Swift Playgrounds.
If Apple's provided the code (or a built-in keyboard option that can do even some of this), I'd appreciate a link to it. Otherwise, how would I go about building a custom keyboard and text field (or at least disable the features like autocomplete that would get in the way)?
Thanks.
As far as I know the only way to do what you describe is to build a Swift Playgrounds app that presents a code editor window. Apple does provide documentation on creating third party iPad Swift playgrounds. I suggest looking it up on Apple's site.

How to highlight text in a textView in Swift?

I would like to highlight a part of text in a UITextView like Pages for iOS or Safari for iOS do. I search the documentation but I can't find a way to do it, maybe because I'm a beginner in iOS development and I miss some crucial info. Somebody can help me?
Screenshot of Pages for iOS:
Screenshot of Safari for iOS:
If you only need to highlight a single, contiguous block of text you can set the selection programmatically. Your examples show multiple discontinuous parts however. For that you are going to need to use an attributed string. There is no other system-provided highlighting function. (There might be a third party library that offers this though - you'll have to search.)

Ignoring Dynamic Text Setting In iOS

I have done a bit of googling around and I am looking for a simple solution to completely ignore the users dynamic text settings in iOS and display them use what I have set in my app itself. My app is a react-native iOS/Android app.
Thank you for any assistance.
Disallow font-scaling
The Text Component supports the prop allowFontScaling.
Specifies should fonts scale to respect Text Size accessibility
setting on iOS.
<Text allowFontScaling={false}>Hello World!</Text>

How to do something like this in Xcode

I developed my app for Android and now I'm trying to do it for IOS. I haven't been able to do this http://oi58.tinypic.com/fon3gp.jpg in Xcode. In Android I used linear and relative layouts to accomplish this. What can I use in Xcode to do something similar? Labels? Text view? Table view?
The page in the link above consists of 1 background, 1 logo, 1 button and one text per pharmacy.
You should be using a UITableView. There are a plenty of tutorials available for you.
Check these :
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/tableview_iphone/CreateConfigureTableView/CreateConfigureTableView.html
or
http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/

How can I inspect elements on native iOS application

I am running an iOS native app on iOS Simulator and would like to inspect the elements on the app to get the ID.
Does anyone knows how this can be done?
Note: Please, this question is for iOS native App not Web based app!
Thanks
It sounds like you may be looking for something like Firebug or the Chrome Inspector for your native app? I'm not sure what you mean by "ID". Interface elements in iOS don't really have IDs the same way DOM elements have IDs.
You should check out the Spark Inspector (http://www.sparkinspector.com/), which allows you to see the views of your app and modify them at runtime - it may help you see what you're looking for. Full disclosure: I am the author of the app ;-)
There is a new app, called Reveal, that does an incredible job.
Not only you can check view's properties, you can also view all the app in a "exploded" 3D view, change the sizes and properties.
Specially for iOS 7, where the view controller starts from the beginning of the screen (and not below the navigation bar), it can be really useful.
You can download the trial at http://revealapp.com and decide which license you should get.
There are two Best ways for this -
Use Accessibility Inspector which is Apples's inbuilt tool so you don't need any other support .
As you will be using Xcode mostly for you code part, there is an option to play UI recording which capture all the actions and elements that you interact with on native app.
You need to inspect the App's Bundle.
Check this answer on stackoverflow, to get the appID: https://stackoverflow.com/a/8883166/933887
Appium has an inspector for ios applications.
This is the link for appium: http://appium.io/
and in this video you can see the inspector in action: https://www.youtube.com/watch?v=jQZTRz2W9xg

Resources