UITextView disabling text selection

Issue How disable Copy, Cut, Select, Select All in UITextView has a workable solution to this that I’ve just implemented and verified: Subclass UITextView and overwrite canBecomeFirstResponder: – (BOOL)canBecomeFirstResponder { return NO; } Note that this disables links and other tappable text content.

UITextView renders custom font incorrectly in iOS 7

I debugged this issue a little, and it seems to be a bug in the way NSLayoutManager layouts the text. As other answers pointed out, UITextView is build around TextKit since iOS7, and thus uses NSLayoutManager internally to layout text. UILabel uses Core Text to layout text directly. Both eventually use Core Text to render … Read more

UITextView text not starting from top

Set the Content Inset like this in your UITextView youtextView.contentInset = UIEdgeInsetsMake(-7.0,0.0,0,0.0); Adjust the Top value the way you want. this shoud fix your problem. EDIT: If you’re having issues with iOS7 or above, try using… [yourTextView setContentOffset: CGPointMake(x,y) animated:BOOL];

UITextView is not scrolled to top when loaded

add the following function to your view controller class… Swift 3 override func viewDidLayoutSubviews() { self.mainTextView.setContentOffset(.zero, animated: false) } Swift 2.1 override func viewDidLayoutSubviews() { self.mainTextView.setContentOffset(CGPointZero, animated: false) } Objective C – (void)viewDidLayoutSubviews { [self.mainTextView setContentOffset:CGPointZero animated:NO]; }

How to insert placeholder in UITextView? [duplicate]

It is not possible to create placeholder in UITextView but you can generate effect like place holder by this. – (void)viewDidLoad { commentTxtView.text = @”Comment”; commentTxtView.textColor = [UIColor lightGrayColor]; commentTxtView.delegate = self; } – (BOOL) textViewShouldBeginEditing:(UITextView *)textView { commentTxtView.text = @””; commentTxtView.textColor = [UIColor blackColor]; return YES; } -(void) textViewDidChange:(UITextView *)textView { if(commentTxtView.text.length == 0) … Read more

UITextView in iOS7 clips the last line of text string

The problem is due to iOS 7. In the text view delegate, add this code: – (void)textViewDidChange:(UITextView *)textView { CGRect line = [textView caretRectForPosition: textView.selectedTextRange.start]; CGFloat overflow = line.origin.y + line.size.height – ( textView.contentOffset.y + textView.bounds.size.height – textView.contentInset.bottom – textView.contentInset.top ); if ( overflow > 0 ) { // We are at the bottom of … Read more

Create UITextRange from NSRange

You can create a text range with the method textRangeFromPosition:toPosition. This method requires two positions, so you need to compute the positions for the start and the end of your range. That is done with the method positionFromPosition:offset, which returns a position from another position and a character offset. – (CGRect)frameOfTextRange:(NSRange)range inTextView:(UITextView *)textView { UITextPosition … Read more

UILabel auto resize on basis of text to be shown

The sizeToFit method worked just great. I did following. UILabel *testLabel =[[UILabel alloc] initWithFrame:CGRectMake(6,3, 262,20 )]; // RectMake(xPos,yPos,Max Width I want, is just a container value); NSString * test=@”this is test this is test inthis is test ininthis is test inthis is test inthis is test in uilabel …this is test in uilabel …this is … Read more

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