How to print the string #"123/456/789" in UIWebView? [duplicate] - ios

This question already has answers here:
How do you remove links from UIWebView?
(2 answers)
Closed 8 years ago.
I have a long text paragraph in which there is a string similar to "123/456/789". When I tried to use UIWebView to display it, the UIWebView always insert something like there is a web link there (an extra underscore and blue color, like 123/456/789 with underscore). But I only want the normal black color just like others. Why does UIWebView add those "link" automatically? How can I avoid that?
Thanks,
Steve

Sounds like the work of a data detector. The web view can automatically detect certain kinds of data, like phone numbers, and make them tappable links. This is often nice, because it's much easier to tap a phone number to make a call than to have to remember it and dial it yourself.
You can specify which types of data the web view should detect by setting its dataDetectorTypes property.

Related

open dialer on label click consisting of number

I want to open dialer on click of label consisting of mobile number in swift 3 iOS.Please help me with this.
You can't make links clickable in a label unless you do it yourself with a gesture recognizer.
I suggest using a UITextView instead. You can turn off editing and make it look just like a label, then enable phone number detectors, set yourself up as the delegate of the text view, and dial the number when the user taps it. Take a look at the textView(_:shouldInteractWith:in:interaction:) UITextViewDelegate method. You should be able to find example code showing how to do it.
EDIT:
I have a project on Github called DatesInSwift that uses clickable text fields as I've described, although it uses a custom URL scheme that links back to the app rather than dialing a phone number like you want. The idea is very similar, though, and you should be able to use the sample app as a guide.

How to add Underline/Bold/Italicize Abilities for UITextView Swift [duplicate]

This question already has answers here:
How to add toggleBoldface option to a UITextView in iOS?
(2 answers)
Closed 5 years ago.
I have been searching for quite a while for a solution as to how to grant users the ability to underline, italicize and bold text in a UITextView but have not been able to find a solid solution. I have realized that I will need to use an NSAttributedString but am not sure as to how to create the UI and format the string so I am able to save it to a database. If you could point me in a proper direction that would be greatly appreciated. Thanks!
The UI is simply an ordinary editable UITextView with allowsEditingTextAttributes set to true.
How you save is up to you, but the most universal solution is probably to pull out the UITextView's attributedText, archive it into an NSData (now known as Data in Swift), and save it off.

How to fade in individual letters of text on iOS [duplicate]

This question already has answers here:
How to Make a Secret iOS App Text Animation
(4 answers)
Closed 8 years ago.
What's the best way to fade in individual letters of a UILabel over time? I'm looking to create something similar to the example below.
http://s11.postimg.org/5s16qmwn5/secret.gif
I wouldn't use UILabel to do this.
I would create a UIView with CATextLayers inside it, one text layer for each character. Then you can animate the text layers independently.
Check out apple's WWDC videos on core animation to learn how it works. It's very simple.
You may want to use NSAttributedText to create your own UITextView or UILabel that does that, basically randomly assigning UIColors with decreasing Alpha to different letters,
It will take a while to find the correct speed and rate of change. Open source it then :)

Custom Image iPhone Keyboard

Before this question is dismissed, let me start by saying I've read the dozens of questions that sound similar. I haven't found anyone that has asked for this specific use case, though, so I'm going to give it a shot.
I would like to create custom images to use (similar to emojis) in a custom keyboard that can be accessed with the globe icon. I understand that I can create a custom keyboard inside my own app, but it will only work within that app. I also understand how the emoji keyboard works.
Is it possible to create a situation where if two people are using the app, though, that the keyboard could be used to input the custom images (emojis) and be viewed only by a receiving user that ALSO has the app - even if the keyboard is being used outside of the custom image keyboard app.
So, basically, there would be a set of images stored within the app and the custom keyboard would reference those images to display whenever the keystroke has been entered and then the receiving phone can locate those images stored within the app to display them (but this could all be done within the native SMS messaging app, not solely in the new custom image keyboard app).
I've researched this a good deal, but can't find a straight answer. Any help or direction would be greatly appreciated!
You could create your own Keyboard that creates somehow special Strings that imply an image. For example could a smiley be encoded like ".CoolSmiley". When you now want to display that text, you should search for patterns you want to recognise. That's how emoji is working. When you type in (y) it will get replaced by a thumb up image because it's recognising the string as a known pattern for a thumb up. This will of course just work inside your app.

How to make Facebook mention like highlighting word in UITextView?

HERE IS SAMPLE IMAGE -->
I'm trying to make text input feature very similar to Facebook's one. The mention that start with # will generate list of my friends name then selecting one will act as something like an object. So deleting the highlighted word will remove whole word in UITextView.
I wonder if that is part of UITextView. Does anyone know how to implement?
Thank you in advance.
I know this is a pretty old question but I've actually made libraries that assist with mentions, when to show the list, does the highlighting etc. It uses attributes on an attributed string to set background.
https://github.com/szweier/SZMentions
https://github.com/szweier/SZMentionsSwift
You'll want to have a look at NSAttributedString. While this class exists in iOS 3.2 or greater, you cannot display it in a UITextView unless you are on iOS 6 or later.

Resources