uitextview

Give UITextView a clickable URL link

↘锁芯ラ 提交于 2020-01-04 05:07:12
问题 Hi I've been on this problem for a while now, I read a couple of posts already an I can't understand how to make a clickable UITextView that sends on internet. Here is my code: func transformText(text: String, underlined: Bool, linkURL: String) -> NSAttributedString { let textRange = NSMakeRange(0, text.characters.count) let attributedText = NSMutableAttributedString(string: text) if underlined{ attributedText.addAttribute(NSUnderlineStyleAttributeName , value: NSUnderlineStyle.styleSingle

UItextView in UITableview, autocorrection bubble not visible

邮差的信 提交于 2020-01-04 04:31:07
问题 I have a UITableView with custom cells. The cells containing one UITextView each and the cell is resizing during user type text in the TextView. My problem is when user is on first row in a TextView autocorrection bubbles wont be visible in the current cell. Is there any workaround or can someone point me to another direction? alt text http://img340.imageshack.us/img340/5414/skrmavbild20100519kl092.png 回答1: If the cell is resizing as the user types, you could set the minimum height of the

How to know the direction of the text?

泄露秘密 提交于 2020-01-03 16:51:15
问题 I need to know the direction of a text depending on the language of the keyboard when typing in a UITextView. For example, if the user is typing in english, then the direction will be "left to right" and if the user is typing in arabic, "right to left". I need that value without doubts and avoiding to hardcoding a matching between each language and its text direction. Is this possible? 回答1: Check this out this method from UITextInput Protocol: - (UITextWritingDirection

Detect URL in NSString

本小妞迷上赌 提交于 2020-01-03 10:56:32
问题 I'm currently using a UITextView in a UITableViewCell in order to make links clickable, but this is giving very poor performance. So I was wondering if it's possible to detect links in a NSString and if there is a link, use the UITextView , otherwise just use a UILabel . 回答1: Absolutely. Use NSDataDetector (NSDataDetector Class Reference) 回答2: I guess you are familiar with regexes to detect URLs, so in order to get one or the other type of view in your cell, you can simply return two

Link in UITextView not working in Swift 4

断了今生、忘了曾经 提交于 2020-01-03 08:31:33
问题 I'm using iOS 11 and Swift 4. I am trying to programmatically generate a link inside a UITextView . All the attributes work (i.e. color, size, range etc.) - but unfortunately, the link does not work. Can anybody tell me why? Here is my code: @IBOutlet weak var textView: UITextView! // Setting the attributes let linkAttributes = [ NSAttributedStringKey.link: URL(string: "https://www.apple.com")!, NSAttributedStringKey.font: UIFont(name: "Helvetica", size: 18.0)!, NSAttributedStringKey

Waiting for UITextView to Finish Updating Text (iOS 7.1)

佐手、 提交于 2020-01-03 04:32:21
问题 I'm programatically updating the attributedText of a UITextView . Following the update I want to call setContentOffset so that I can scroll to position the new text. The problem I'm having is that there's a delay in the text view updating its text. With the following code the debug log outputs the same value: - (void)appendToTextView:(NSString*)text { CGFloat bottomOfCurrentContent = _pastedText.contentSize.height; NSLog(@"Bottom of content, before = %f", bottomOfCurrentContent); NSString*

How to intercept click on link in UITextView?

强颜欢笑 提交于 2020-01-02 23:13:23
问题 Is it possible to perform custom action when user touch autodetected phone link in UITextView. Please do not advice to use UIWebView instead. And please don't just repeat text from apple classes reference - certainly I've already read it. Thanks. 回答1: 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

Adding custom border around uitextview but little beyond its bounds

北慕城南 提交于 2020-01-02 20:59:37
问题 How can i add border to uitextview little beyond its bounds. Can i give the location for border or do i have to add custom border and give position to it.Any help will be appreciated. 回答1: it's easy task. you have to add quartz core framework and write the following line CALayer *imageLayer = textView.layer; [imageLayer setCornerRadius:10]; [imageLayer setBorderWidth:1]; imageLayer.borderColor=[[UIColor lightGrayColor] CGColor]; 回答2: Add "QuartzCore" Framework And Import It in your HeaderFile

how can i get selectedRange.location value?

邮差的信 提交于 2020-01-02 20:10:48
问题 i want to get a cursor position from UITextview, i have implement the code in How to find a pixel-positon of a cursor in UITextView? post, the algorithm is based on algorithm in Pixel-Position of Cursor in UITextView. my problem is, i can't get the selectedRange.location value after keyboard appear in the 2nd time, cause it always tell that the value of location is 2147483647, which means not found. This is my implementation : -(void)getCursorPosition{ NSRange originalPosition = self

how can i get selectedRange.location value?

本小妞迷上赌 提交于 2020-01-02 20:10:02
问题 i want to get a cursor position from UITextview, i have implement the code in How to find a pixel-positon of a cursor in UITextView? post, the algorithm is based on algorithm in Pixel-Position of Cursor in UITextView. my problem is, i can't get the selectedRange.location value after keyboard appear in the 2nd time, cause it always tell that the value of location is 2147483647, which means not found. This is my implementation : -(void)getCursorPosition{ NSRange originalPosition = self