Links within UILabels to Native Functions - ios

As the title conveys, I want to have a UILabel that will contain phone number, address, email, etc. and I am looking for a way to link to native functions (i.e. when a user clicks on phone number, the dialer is launched and when the address is clicked, the Maps are launched). I've tried to research this and seems like UILabels may not be formattable. One way I could do this is to create custom UIButtons, but that seems tedious in terms of scalability, and may not be the best solution.
Just to give some context, the same exact thing is possible in Android:
TextView someText = (TextView) findViewById(R.id.about);
someText.setAutoLinkMask(Linkify.ALL);
contact.setText("Toll Free: 888-888-8888");
Will work just fine and link the number to the phone dialer. It works the same with an address by redirecting to the Maps application.
Is this possible in iOS and if not, what are the workarounds?
Cheers.

Try the UITextView instead, and check out the dataDetectorTypes property.

What's wrong with using a UIButton and link it to an IBAction for each of the fields? Or maybe you can look into Segmented Control, though I personally don't have any experience with it.

https://github.com/mattt/TTTAttributedLabel
The above link has custom label to your requirement

Related

Implementing a localisable string in IOS with hyperlink

I am building an app, and would like to create this feature.
"By using our services, you agree to our terms of service"`
This label/text should also be localisable in Japanese and German,
and when the user clicks on Terms of Service, the app should launch a webview to an external website.
I've tried UILabel and ActiveLabel, but they don't seem to be able to localise/translate.
Anyone have any ideas or suggestions?
Thanks and appreciated.
I've tried UILabel and ActiveLabel, but they don't seem to be able to
localise/translate.
ActiveLabel is merely a subclass of UILabel and I use it the same case with you for a tappable labels that opens up a UIWebView, therefore you can just pass a localised string to your activeLabel object easily.
For more information on how to do localisation, there are tons of resources here on Stackoverflow, Youtube, and Google.
Sample: https://www.youtube.com/watch?v=IV1x9FgQ5v0

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.

What should i use either UITextView or UIWebView in objective c?

I am working at chatApplication where i need to enable the phone number and link detection while magnifying property set to no like whatsApp and iMessage do. What component should i use for that?
go with the textview. because it'll be also possible with textview to detect number and link. webview also good option.
but as you mention, you want to make chat Application than if you also want to provide the functionality for select,copy,etc. than Textview is the good one.

How to make long text accessible

I'm trying to make my app more accessible but I have a problem. Part of my app consists of pieces of advice, each composed of an UIScrollView with long text. (The text is a UIImage I prepared with Photoshop ).
I would like to make it accessible so that the users could listen to all the advice and pause it whenever they want. I thought of using UIAccessibilityLabel but the text is too long.
Thanks in advance for your help.
Let me preface this by saying I am not an iOS developer but am a long time blind iOS user.
There is no way to easily pause the reading of text and resume at the exact same spot that I know of. According to the documentation, I've found accessibilityLabel is meant to provide accessibility information that can be conveyed in under a sentence. An option I can think of would be to test whether VoiceOver is enabled using UIAccessibilityIsVoiceOverRunning. If this is true, you could put your text into a text view, and display that instead of your UIImage.
A textView will allow a VoiceOver user to read the text by character, word, or line, which is the best option available. If VoiceOver isn’t running, your test will return false, the UIImage will be displayed as normal, and the user won’t see anything different.

iOS autocomplete feature

What most people mean by autocomplete is that the app has a textview/searchbar/whatever which accepts user input. Attached to this component is a tableview which keeps updating based on the user input. This is a well researched topic and is now relatively easy to implement thanks to the UISearchDisplay controller.
Now here is what I want. When the user is typing in some text in the UISearchBar, there will be no searchdisplaycontroller. Instead, I want the app to do something like Google Instant on desktops. That is, if I type "Goog", the searchbar should show Goog*le. So the suggestion "le" should be in a lighter font than the rest of the user input string Google. So I don't want an auto-suggest feature, I want an autocomplete feature.
Any ideas on how I can do this?
Thanks!
Alternatively, you can use this UITextField subclass (inspired by DOAutocompleteTextField):
https://github.com/hoteltonight/HTAutocompleteTextField
It's got a few more features and is actively developed. The example shows you how to use an array as the data source for the autosuggest text.
I haven't tried it but here's a control that appears to do what you're asking for:
http://cocoacontrols.com/platforms/ios/controls/doautocompletetextfield

Resources