open dialer on label click consisting of number - ios

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.

Related

How do i know when a double click is made on focused element with voice over accessibility?

Facing an issue where double tapping with voice over on, the link inside focused UITextView is not opening in Safari in iOS 9. It works fine in iOS 10 and 11. Any suggestions for same?
Also i need to know when the user double taps on screen to perform action on focused item with voice over on , also which view was in focus?
Thanks in advance!!
FIRST QUESTION: to open a link in a UITextView, there's a specific VoiceOver gesture I already explained in a detailed answer and that should always work.
SECOND QUESTION: if you want to know the focused element on which a double tap is made, the best way is to use the UIAccessibilityFocus informal protocol using the accessibilityElementIsFocused method for instance.
Take a look at the provided links where code snippets are available (Objc + Swift).

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.

Have a custom number pad in iOS to dial number

I am making an app through which the user dials the number.I want to design my own number pad with delete button.I can make them easily by taking 10 buttons on the UIView and placing them accordingly and whenever the button presses i will have the button number updated in my dialer box.
I want to know whether my approach is good or there is something else through which i can achieve this in a better manner.
You can do this by using following 3 ways,
As comment given by #nerowolfe i.e. by using keyboardType equals to UIKeyboardTypePhonePad...
You can get many keyboard type click here
Using UIView with array of buttons inside it as you think.
If you are building this app for ipad then you should use popover instead of UIView or any custom vies. Using popover is more standard way than custom view for ipad. It gives benefits like,
Requires small space
Good look
Standard way
My suggestion to u is that if you are building app for iphone then option 1 or 2 is better and if you are building it for ipad option 3 is great...

How to detect link from tweets in ios native app

I am showing tweets in an iOS native app. I am showing the tweets on the UILabel in a UITableView.
I want user able to click on the link that are part of tweet text.
But the links in tweet text are not prefix by http:// or www. Instead, the link contains # and # as prefix.
I used UITextView with datadetector type property but not able to detect link.
I read some article that the UIWebView can be use to detect link; but I don't think I should use UIWebView in UITableView cell.
Is there any way to achieve this in iOS? My app supports iOS 5+.
There's nothing provided by the SDK that will do this out of the box, but the necessary pieces are there to build your own UILabel subclass that will handle this kind of data detection. If that's not something you want to take on, take a look at TTTAttributedLabel.

Links within UILabels to Native Functions

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

Resources