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

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.

Related

iOS App: Possible to make keyboard recommendations?

In an iOS application, is it possible to make own keyboard suggestions if the user taps a specific UITextField? The suggestion should only appear if the UITextField is empty.
By keyboard recommendations I mean the Predictive Keyboard:
Swift code is preferred.
Thanks!
I don't think you can provide suggestions to the actual keyboard so they get presented, but what you can do is write your own inputAccessoryView to be there instead, and handle the tapping/appending of text yourself, and possibly disable the completion from the keyboard. This is essentially what the messaging apps do to present a bar with buttons to add photos and attachments when writing.
Since you don't mention what you're trying to accomplish I don't know if this would make sense. Let me know if you want me to elaborate on how to do this in code.

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 highlight text in a textView in Swift?

I would like to highlight a part of text in a UITextView like Pages for iOS or Safari for iOS do. I search the documentation but I can't find a way to do it, maybe because I'm a beginner in iOS development and I miss some crucial info. Somebody can help me?
Screenshot of Pages for iOS:
Screenshot of Safari for iOS:
If you only need to highlight a single, contiguous block of text you can set the selection programmatically. Your examples show multiple discontinuous parts however. For that you are going to need to use an attributed string. There is no other system-provided highlighting function. (There might be a third party library that offers this though - you'll have to search.)

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