NSAttributedString text as button? [duplicate] - ios

This question already has answers here:
UILabel - string as text and links
(6 answers)
Closed 9 years ago.
I want to allow my users to include a tappable element in a paragraph of text they've written inside my app. Similar behaviour to this is a twitter client which has tappable links and mentions as part of the text. I presume the best way to do this would be to use an NSAttributedString. I'm unsure how I could get some of the text to be tappable though. How could I do this?

you can use a UIWebView and pass in an html string,
<p>Some text going here <button> clickable text </button> more text <\p>
and there is a delegate method for when a uiweb view sends out some request for clicking the
button
you can record the location of the text you want to click and then manually test if the user taps in that area
you can pragmatically create custom buttons as you see fit and place them in the places of the words
best way to do it in general is the uiwebview which html already has text formatting , but i don't know how complex your app is so that might not be an option

Related

How to format a text like bold/italic in UITextField in Swift iOS?

Here consider this image. I have taken a toolbar with icons for text formatting. After selecting that sentence if I hit B (bold) it should be bold. Even I need that too if I select bold then further text to be show as bold. Consider this textbox UITextField. Incase you have some good reference like github you are welcome. I have already spend two days in a row in SO but not get any proper solution. One bold function is enough for me.

iOS Swift Clickable Text

I need to make text within a UITextView to be clickable. Basically I want to show more information on the text being clicked on. In PHP I would surround the text I want clickable in square brackets and then make anything in square brackets a link (i.e. [More Info]). How can I do something similar in Swift? I know I can turn on data detectors to detect http links but I don't want http showing.

How to display text on iOS

I'm new to Xcode an trying to design a basic text app. I'm wondering what the best way to display mutable text that cannot be edited by the user. Thanks for any help.
Depending on how much text you want display
1) UILabel for short things...won't be editable
2)and UITextView for large texts (set editable property to false)

QuickDialog: How to create a field for long, multiline text?

I am using QuickDialog to create a form in my iOS app. For one of the items that I am asking users about, I would prefer a multi-line text field as it's an open-ended question (e.g., do you have any questions?). QEntryElement only has a single line, and the space to type is pretty small on an iPhone. Any suggestions for how to do a larger text entry space using QuickDialog?
Instead of QEntryElement, use QMultilineElement. It works exactly the same way - the only problem being that QMultilineElement does not display what the user entered on the main form screen.

iOS: URL link in UITextField with different text

I want to insert a URL hyperlink into a UITextField that has different display text.
This is super easy in html:
Go To Google
How can I do this in iOS?
You can change the text style inside your UITextField via an attributed string sent to the text field's "attributedText" property.
However, what I suspect you really want to do is have a link that's clickable. I would recommend using a UIButton with a custom type (i.e. no border) and you can set the color and the underline style.
But like Evan said, if you have multiple lines of text, it may be smarter to use a UITextField where you set "editable" to NO and turn on the LINK traits (both of these you can do from the object inspector in Xcode).
Alright, so here's what I did to get what I wanted. I used UIWebView, and simply linked it to an html page in the project that has the text, and hyperlink at the bottom with different text displayed.
Answer is here :
If you want it as clickable Hyperlink,
NSString *string = #"Go To Google";
You need to add "BACKWARD SLASH" before ". That's it.

Resources