My plan is to assign the selected text to a string variable. But for now I'd like to simply print it in real time. Is there a way to retrieve and assign it in real time?
I've tried to use the answers from the below link and couldn't do much:
How do I get the selected text from a WKWebView from objective-C
Thanks in advance
Related
Anyone know how you get the current text of a JSQMessagesViewController? When the view disappears I wan to cache the text the user has typed in so that when they return I can repopulate.
Found it.
self.inputToolbar.contentView.textView.text!
Appium
Python
iOS
el.text and get_attribute('label') etc. all seem to pulling accessibility information. Is there a way to pull the actual text that is displayed on screen using Appium? I need to be able to pull for a given element.
It does not return visible text if you use .text
You need to ask the developer to add a new attribute in the iOS code with the actual mention of the original url text. Then you will be able to see the new attribute in the Appium element locator table. If this is not done there is no value in the appium element locator table to give you the visible text
You can use .text
element = driver.find_element_by_class_name("class_name").text
print(element)
it will return you text and verify f you required.
Try this one it will help you
element = driver.find_element_by_class_name("class_name").get_attribute('text')
print(element)
or
Second one - Give you exact text from android ui
element = driver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.EditText\")").get_attribute('text')
print(element)
I am quite sure, that .text will give you the element's text when the element is visible.
Beware, Appium does give you an empty string here, if it deems the element not visible (out of screen- bounds or hidden or behind another element). If you need to get the text of elements which are not visible, you may try this one driver.find_element_by_class_name("class_name").get_attribute('textContent')
I`m starting in Objective-c this Year and I found nothing that could help me in the logic of how elaborate it:
Look!
I have a UITableView with a list of drugs. When I click on any medication, I'm taken to a DetailViewController that displays the text information about this drug. In this text, I want every time a drug name appear, it appears as if it were a “link”. So when the user clicks, it will be taken to other remedy detailviewcontroller without need to go back to the list of remedies! What is the better way to implement this?
I thought about passing an array with all drugs for DetailTableView controller via Segue, and then conduct a search for any of the remedies present in the text, but i don't know how to turn that word into a link, or set a function to become part of the text (the drug name) clickable
Just to make it clear, let's assume that we are reading the details of the text on the drug called Amoxicillin:
“Amoxicillin drug works better than erythromycin”
What I want is that the name Erythromycin become some kind of link, so when the user clicks on it, is brought to the screen details about erythromycin. Do you guys understand what i mean?
P.S.: I saw that the UITextView has an option called "Links" in attribute inspector, but i have no idea how to use it or if this is for what i want
Thank you all again!!
Use UITextView And select these attribute.
Is it possible to add a text link into a TextView? I want the link to perhaps behave like a button, where I can assign an action to it.
EDIT: When I say assign an action, I mean actually giving it something in the code. I'm wondering if it's possible to dynamically add a "button" into text that I can assign a coded action to.
Live scenario
Think of something like a dictionary app. Maybe the definition of one word uses another word that you might not know the definition of, so being able to click on that word to instantly search it rather than having to type it in would be a nice user friendly feature. It seems rather unlikely, though, I guess.
I would recommend using NIAttributedLabel from Nimbus, an open source iOS library. You can specify text ranges that are links, and you get delegate messages sent when a user taps on it.
Main Nimbus site: http://nimbuskit.info/
NIAttributedLabel docs: http://docs.nimbuskit.info/interface_n_i_attributed_label.html
in the inspector, go to the Text View Attributes tab then make sure "Detect Links" is checked.
Yes you can. Add the URL into the text view, then open up the Attributes Inspector. You will see an option in there to detect links.
I know of a way, but its a LOT of work. First, you have an NSAttributedString that you have the text view display. Second, attribute the range of text you want to be the button. Third, assign a tap gesture recognizer to the text view and in the method called by the recognizer, you'll use core text to determine if the tap happened over the range of text that represents the buttons.
Heres how youll use core text: create a framesetter with the attributed string. Create a frame from the framsetter with the shape of a square that is the frame of the text view, inset by the padding of the text view. The frame will allow you to get the y origins of every line in the text view and and once you know what line the tap happened on, you can use the line to then figure out exactly what character was tapped on that line by giving it an x offset. Once you know character index on the line, you can add it to the beginning of the range of the line and get the index of the character within the whole string. Then you can check if its within the range of the text that is your button. If it is, you can then call a method to simulate a target action type behavior.
Ive explained the process of how to accomplish this and specified what kinds of core text objects youll need, ill let you look up the specific api details:
https://developer.apple.com/library/mac/documentation/Carbon/Reference/CoreText_Framework_Ref/_index.html#//apple_ref/doc/uid/TP40005304
You can also use my objc core text wrapper:
https://github.com/mysterioustrousers/MYSCoreText
What about CoreText? It Can draw many kinds of Text .
I have UITextView in which as the user types I would like to suggest a few words (like in a popup) as is displayed for misspelled words.
There are custom words that I have in a an array which should be used as suggestions
For example if the user starts to type "carpen" I would like to suggest "carpenter1", "carpenter2", "carpenter3", so that the user can select any one of the 3 suggestions or choose to type a new one.
UITextChecker
Is completionsForPartialWordRange:inString:language: something that I can use ? If so how can I make pass the array to the popup ?
Question:
How would I be able to achieve something like what is shown in the image ?
Let me know if there is a different approach