uitextview

UITextView: How to really disable editing?

China☆狼群 提交于 2020-06-27 07:28:43
问题 I am trying to disable editing on my UITextView . I have tried [aboutStable setUserInteractionEnabled: NO] , but it causes the page to not be accessible. Here is the current code. - (void)loadTextView1 { UITextView *textView1 = [[UITextView alloc] init]; [textView1 setFont:[UIFont fontWithName:@"Helvetica" size:14]]; [textView1 setText:@"Example of editable UITextView"]; [textView1 setTextColor:[UIColor blackColor]]; [textView1 setBackgroundColor:[UIColor clearColor]]; [textView1

Single extension for UITextView and UITextField in Swift

☆樱花仙子☆ 提交于 2020-06-23 01:44:12
问题 I want to create a single extension for both UITextField and UITextView and add a below method to it: func addDoneButtonOnKeyboardWith(selector : Selector) { let keyBoardToolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: 320, height: 30)) let barButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: selector) let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) keyBoardToolBar.items = [flexibleSpace, barButtonItem]

Single extension for UITextView and UITextField in Swift

馋奶兔 提交于 2020-06-23 01:43:23
问题 I want to create a single extension for both UITextField and UITextView and add a below method to it: func addDoneButtonOnKeyboardWith(selector : Selector) { let keyBoardToolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: 320, height: 30)) let barButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: selector) let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) keyBoardToolBar.items = [flexibleSpace, barButtonItem]

Control spacing around custom text attributes in NSLayoutManager

痴心易碎 提交于 2020-06-09 12:50:47
问题 I’ve got a custom NSLayoutManager subclass I’m using to draw pill-shaped tokens. I draw these tokens for substrings with a custom attribute ( TokenAttribute ). I can draw no problem. However, I need to add a little bit of “padding” around the ranges with my TokenAttribute (so that the round rectangle background of the token won’t intersect with the text). In the above image, I’m drawing my token’s background with an orange colour, but I want extra padding around 469 so the background isn’t

NSLayoutManager with multiple NSTextContainers causes UITextViews to not be selectable/editable

五迷三道 提交于 2020-05-10 20:56:11
问题 I am trying to achieve a multi page text editing layout, as in Pages, MS Word, ... . On OS X I can achieve this by creating one NSLayoutManager with one NSTextStorage for multiple NSTextViews. Each NSTextView has its own NSTextContainer. See below code for OS X. A simple example with text spreading between two NSTextViews: import Cocoa class ViewController: NSViewController { let layoutManager = NSLayoutManager() let textStorage = NSTextStorage(attributedString: NSAttributedString(string:

NSLayoutManager with multiple NSTextContainers causes UITextViews to not be selectable/editable

笑着哭i 提交于 2020-05-10 20:55:56
问题 I am trying to achieve a multi page text editing layout, as in Pages, MS Word, ... . On OS X I can achieve this by creating one NSLayoutManager with one NSTextStorage for multiple NSTextViews. Each NSTextView has its own NSTextContainer. See below code for OS X. A simple example with text spreading between two NSTextViews: import Cocoa class ViewController: NSViewController { let layoutManager = NSLayoutManager() let textStorage = NSTextStorage(attributedString: NSAttributedString(string:

NSLayoutManager with multiple NSTextContainers causes UITextViews to not be selectable/editable

不打扰是莪最后的温柔 提交于 2020-05-10 20:55:48
问题 I am trying to achieve a multi page text editing layout, as in Pages, MS Word, ... . On OS X I can achieve this by creating one NSLayoutManager with one NSTextStorage for multiple NSTextViews. Each NSTextView has its own NSTextContainer. See below code for OS X. A simple example with text spreading between two NSTextViews: import Cocoa class ViewController: NSViewController { let layoutManager = NSLayoutManager() let textStorage = NSTextStorage(attributedString: NSAttributedString(string:

Layout problems after replacing UILabel with UITextView in a UITableViewCell

断了今生、忘了曾经 提交于 2020-04-18 05:43:26
问题 I've got basic chat functionality as part of an App I'm building. It is basically a UITable View where the UITableViewCell only contains a UILabel (the chat message text) and a UIView (serving as a speech bubble, surrounding the text. Here's the code: class ChatMessageViewCellController: UITableViewCell { var ChatMessageText = UILabel() var ChatBubble = UIView() var leadingConstraint: NSLayoutConstraint! var trailingConstraint: NSLayoutConstraint! var isIncoming: Bool! { didSet { if self

Layout problems after replacing UILabel with UITextView in a UITableViewCell

吃可爱长大的小学妹 提交于 2020-04-18 05:43:13
问题 I've got basic chat functionality as part of an App I'm building. It is basically a UITable View where the UITableViewCell only contains a UILabel (the chat message text) and a UIView (serving as a speech bubble, surrounding the text. Here's the code: class ChatMessageViewCellController: UITableViewCell { var ChatMessageText = UILabel() var ChatBubble = UIView() var leadingConstraint: NSLayoutConstraint! var trailingConstraint: NSLayoutConstraint! var isIncoming: Bool! { didSet { if self

UITextview show vertical scrollbar all the time

被刻印的时光 ゝ 提交于 2020-04-10 06:03:55
问题 I am trying to show vertical scrollbar on uitextview at the beginning with the code but it isn't doing so. UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(10, 80,self.view.frame.size.width-20,self.view.frame.size.height/2)]; [txtView setEditable:NO]; [txtView setSelectable:NO]; [txtView setText:self.secret]; [txtView setBackgroundColor:[UIColor clearColor]]; [txtView setTextColor:[UIColor whiteColor ]]; [txtView setFont:font]; txtView.showsVerticalScrollIndicator=YES; [txtView