uitextviewdelegate

UITextView doesn't show InputAccessoryView on first click

拜拜、爱过 提交于 2019-12-03 11:14:46
问题 I use the UITextViewDelegate and add a InputAccessoryView in textViewDidBeginEditing: [textView setInputAccessoryView:doneBar]; The doneBar is not nil and it appears on second opening. Has anyone else this problem? Thanks in advance. 回答1: I imagine when the code has reached textViewDidBeginEditing: that it is too late to make changes to the UI. Perhaps you can move your code to an earlier event, maybe textViewShouldBeginEditing: 来源: https://stackoverflow.com/questions/5803267/uitextview

iPhone: how can I activate a text field programmatically (and not wait for the user to touch it)

对着背影说爱祢 提交于 2019-12-02 06:59:39
I have a UIViewController that is a UITextFieldDelegate, and I would like the keyboard for its text field to appear as soon as the user navigates to this view, without having to actually touch the text field. It would also be nice to be able to "dismiss" the entire view when the keyboard is dismissed. I am loading the view from a xib file. I don't have an ivar in the code for the UITextField as yet. I would guess I need one. At this point I am just relying on the delegate to pop up the keyboard. (I know its not a UITextViewDelegate, like the tag says, but I am new to stackoverflow and can't

Detect UITextView scroll location

偶尔善良 提交于 2019-12-01 03:38:21
I am trying to implement a form of a Terms & Conditions page where the "Proceed" button is only enabled once the user has scrolled to the bottom of a UITextView. So far I have set my class as a UIScrollView delegate & have implemented the method below: - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { NSLog(@"Checking if at bottom of UITextView"); CGPoint bottomOffset = CGPointMake(0,self.warningTextView.frame.size.height); //if ([[self.warningTextView contentOffset] isEqualTO:bottomOffset]) { } } I have commented the if statement because I am not sure how to check if the

UITextView attributedText and syntax highlighting

自古美人都是妖i 提交于 2019-11-30 13:05:48
问题 Background So, with iOS 6 an UITextView can take an attributedString, which could be useful for Syntax highlighting. I'm doing some regex patterns in -textView:shouldChangeTextInRange:replacementText: and oftentimes I need to change the color of a word already typed. I see no other options than resetting the attributedText, which takes time. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { //A context will allow us to not call

UITextView attributedText and syntax highlighting

六月ゝ 毕业季﹏ 提交于 2019-11-30 05:23:05
Background So, with iOS 6 an UITextView can take an attributedString, which could be useful for Syntax highlighting. I'm doing some regex patterns in -textView:shouldChangeTextInRange:replacementText: and oftentimes I need to change the color of a word already typed. I see no other options than resetting the attributedText, which takes time. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { //A context will allow us to not call -attributedText on the textView, which is slow. //Keep context up to date [self.context

Limit number of characters in uitextview

只谈情不闲聊 提交于 2019-11-27 10:29:07
I am giving a text view to tweet some string . I am applying the following method to restrict the number of characters to 140 in length. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if([text isEqualToString:@"\b"]){ DLog(@"Ohoooo"); return YES; }else if([[textView text] length] > 140){ return NO; } return YES; } The code is working nicely except the first condition that backspace is not working. suppose that I have reached the limit of 140 characters so that the method will give me false and the user can not insert more

Limit number of characters in uitextview

☆樱花仙子☆ 提交于 2019-11-26 10:15:49
问题 I am giving a text view to tweet some string . I am applying the following method to restrict the number of characters to 140 in length. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if([text isEqualToString:@\"\\b\"]){ DLog(@\"Ohoooo\"); return YES; }else if([[textView text] length] > 140){ return NO; } return YES; } The code is working nicely except the first condition that backspace is not working. suppose that I have