uitextview

How to disable select functionality in UITextView?

蓝咒 提交于 2020-01-11 13:01:04
问题 I want to create a text display area (either UILabel or UITextView) in my iPhone app which (1) allows scrolling and (2) does not allow selection. I have tried the following techniques unsuccessfully: Basic UILabel: Didn't allow scrolling, and clipped text to the bottom of UILabel space on screen. Giant UILabel within a UIScrollView: the UILabel kept placing the text (vertically) at the center of the giant UILabel, so it often was outside of my UIScrollView. UITextView: So far this approach

UITextView as InputAccessoryView doesn't render text until after animation

て烟熏妆下的殇ゞ 提交于 2020-01-11 07:18:33
问题 When showing the detail viewcontroller for the first time, the inputAccessoryView will render the text immediately, but when you go back and try it again, the text doesn't get rendered untill the animation completes. See demo project here: https://github.com/SabatinoMasala/accessoryview-demo/ If anyone has a resolution, explanation or workaround, I'd be glad to hear it! 回答1: I tried messing with your project and, unfortunately, I saw the same behavior that you did. This may be a bug in UIKit.

what to use instead of scrollRangeToVisible in iOS7 or TextKit

橙三吉。 提交于 2020-01-11 04:49:14
问题 In previous versions of iOS, my UITextView will scroll to the bottom using [displayText scrollRangeToVisible:NSMakeRange(0,[displayText.text length])]; or CGFloat topCorrect = displayText.contentSize.height -[displayText bounds].size.height; topCorrect = (topCorrect<0.0?0.0:topCorrect); displayText.contentOffset = (CGPoint){.x=0, .y=topCorrect}; But the former will now have the weird effect of starting at the top of a long length of text and animating the scroll to the bottom each time I

Is there a way to put UITextView's scroll indicator to outside UITextView?

夙愿已清 提交于 2020-01-11 02:11:52
问题 It might be a silly question. I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView. However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No. It would be perfect if a scroll indicator of UITextView appears outside UITextView. In the attached

How to intercept long press on UITextView without disabling context menu?

血红的双手。 提交于 2020-01-10 18:54:28
问题 I want to intercept long press on UITextview, but don't want to disable the context menu option at the same time. If I use gesture recognizer on textview, it will disable context menu so I am using the method like below now. - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { //fire my method here } But, it only fires the method when context menu shows up after the user long press some words. So when the user long press a blank space, then only the magnifying glass shows up, I can't

Clear button on UITextView

两盒软妹~` 提交于 2020-01-10 14:18:21
问题 How can I add a clear button (cross inside a circle) for UITextView like UITextField has? 回答1: just make a uibutton and put it on uitextview and set its action for clear text view; uitextview.frame = (0,0,320,416); uibutton.frame = (310,0,10,10); [uibutton setimage:@"cross.png" forcontrolstate:uicontrolstatenoraml]; [uibutton addTarget:self action:@selector(clearButtonSelected:) forControlEvents:UIControlEventTouchUpInside]; -(void)clearButtonSelected{ uitextview=@""; } hope you want to clear

Clear button on UITextView

不问归期 提交于 2020-01-10 14:18:10
问题 How can I add a clear button (cross inside a circle) for UITextView like UITextField has? 回答1: just make a uibutton and put it on uitextview and set its action for clear text view; uitextview.frame = (0,0,320,416); uibutton.frame = (310,0,10,10); [uibutton setimage:@"cross.png" forcontrolstate:uicontrolstatenoraml]; [uibutton addTarget:self action:@selector(clearButtonSelected:) forControlEvents:UIControlEventTouchUpInside]; -(void)clearButtonSelected{ uitextview=@""; } hope you want to clear

Get the frame of the keyboard dynamically

旧时模样 提交于 2020-01-09 13:11:42
问题 Is it possible to get the frame, actually its height, of the keyboard dynamically? As I have a UITextView and I would like to adjust its height according to the keyboard frame height, when the input method of the keyboard is changed. As you know, different input methods may have different keyboard frame height. 回答1: try this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil]; - (void)keyboardWasShown:

UITextView startInteractionWithLinkAtPoint crash iOS 11 only

感情迁移 提交于 2020-01-09 10:48:07
问题 So I experience crash in UItextview while user interacts with URL link there. All crash reports have iOS version 11 only. This looks like well-known bug in iOS 9, but there is no single report iOS versions lower than 11, and also in report I found interesting line: UITextGestureClusterLinkInteract smallDelayRecognizer: which came with iOS 11 (http://developer.limneos.net/?ios=11.0&framework=UIKit.framework&header=UITextGestureClusterLinkInteract.h). Anyway, for now I fixed it with @available

Read More/Less with Swift 3

烈酒焚心 提交于 2020-01-09 10:33:49
问题 I want to add " Read more " at the end of the paragraph. When I click on the "Read more" text, it should be expand and display " Less " at the end. The texts will be collapsed when click on "Less" text. I find many sample work in google. But, I don't understand clearly and most projects are implemented with Objective-C. I also find it in youtube. I would like know very sample code to implement this with Swift 3 . Can I implement without using any additional library? Please help me. 回答1: