How to detect link from tweets in ios native app - ios

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.

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.

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.)

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.

Markup feature in images in swift

I've created a chat app, where user can chat and share images. Now I need to add feature where user can edit and perform some annotation on images. I've heard from iOS 9 there's a new feature called markup to perform editting on images. I've checked UIActivityViewController and couldn't find in it. Is this feature available and can it fit to my requirement? If not, is there any other alternatives that I can approach?
Yes you are Right Markup feature is available from ios 9.
iOS 9 has introduced a set of markup tools for images that you attach
with a message in the Mail app.
To use this feature,
1) Open the Mail app and compose a new message (or reply to an old one if that’s what you need to do).
2) Tap and hold on the message body area and in the floating actions bar, tap the Insert Photo or Video option. From your camera roll, insert a photo.
3) Tap and hold on the photo and in the floating actions bar that appears on the photo, tap the new ‘Markup’ option.
--> Your photo will be enter in Editing mode.
Markup tool will look like this ,
From the link whats-new you will find that apple implement markup option for mail.
So, As per your Question , Markup image facility provided bydefault by apple in Mail. so, i think you can't implement it programatically. but when user will open the mail from UIActivitycontroller from your application then user will get Markup feature with following above procedure. (But user have to manually do process to enable Markup feature)
You can also check video on youtube ,
How to markup and annotate an attachment in iOS 9
Reference link regarding markup feature,
ios-9-markup-annotate-email-attachments
I hope this info is helpful for you.

Resources