How to intercept click on link in UITextView?

Update: From ios10, – (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction; From ios7 and Later UITextView has the delegate method: – (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange *NS_DEPRECATED_IOS(7_0, 10_0, “Use textView:shouldInteractWithURL:inRange:forInteractionType: instead”);* to intercept the clicks to links. And this is the best way to do it. For ios6 and earlier a nice way to do this … Read more

How disable Copy, Cut, Select, Select All in UITextView

The easiest way to disable pasteboard operations is to create a subclass of UITextView that overrides the canPerformAction:withSender: method to return NO for actions that you don’t want to allow: – (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (action == @selector(paste:)) return NO; return [super canPerformAction:action withSender:sender]; } Also see UIResponder

Swift: Display HTML data in a label or textView [duplicate]

For Swift 5: extension String { var htmlToAttributedString: NSAttributedString? { guard let data = data(using: .utf8) else { return nil } do { return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil) } catch { return nil } } var htmlToString: String { return htmlToAttributedString?.string ?? “” } } Then, whenever you want to … Read more

Detecting taps on attributed text in a UITextView in iOS

I just wanted to help others a little more. Following on from Shmidt’s response it’s possible to do exactly as I had asked in my original question. 1) Create an attributed string with custom attributes applied to the clickable words. eg. NSAttributedString* attributedString = [[NSAttributedString alloc] initWithString:@”a clickable word” attributes:@{ @”myCustomTag” : @(YES) }]; [paragraph … Read more

How can I change the color of a part of a TextView?

Spannable is more flexible: String text2 = text + CepVizyon.getPhoneCode() + “\n\n” + getText(R.string.currentversion) + CepVizyon.getLicenseText(); Spannable spannable = new SpannableString(text2); spannable.setSpan(new ForegroundColorSpan(Color.WHITE), text.length(), (text + CepVizyon.getPhoneCode()).length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); myTextView.setText(spannable, TextView.BufferType.SPANNABLE);

Getting and Setting Cursor Position of UITextField and UITextView in Swift

The following content applies to both UITextField and UITextView. Useful information The very beginning of the text field text: let startPosition: UITextPosition = textField.beginningOfDocument The very end of the text field text: let endPosition: UITextPosition = textField.endOfDocument The currently selected range: let selectedRange: UITextRange? = textField.selectedTextRange Get cursor position if let selectedRange = textField.selectedTextRange { … Read more

How to style UITextview to like Rounded Rect text field?

There is no implicit style that you have to choose, it involves writing a bit of code using the QuartzCore framework: //first, you #import <QuartzCore/QuartzCore.h> //….. //Here I add a UITextView in code, it will work if it’s added in IB too UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 220, 200, 100)]; //To make the border … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)