1

I've created a textView in this way:

UITextView*txtview = [[UITextView alloc] initWithFrame:CGRectMake(x,y,25,25)];
txtview.backgroundColor = [UIColor clearColor];
txtview.textColor = [UIColor redColor];
txtview.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:18];
txtview.inputView = segmentKB;
txtview.delegate = self;
[self.view addSubview:txtview];
[txtview sizeToFit];

My problem is that when I edit this text view, it moves up of some pixels.

How can I solve this and why does it happen? The inputView is a segmented control, but the same problem also happens with a normal keyboard.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
charles
  • 713
  • 1
  • 6
  • 16

4 Answers4

2

change height of txtview from 25 to 35.

pskow
  • 135
  • 1
  • 9
1

Its nothing to do with setting up any property,its been developed likewise by apple's engineer.Use UITextField instead of UITextView or increase the height of UITextView atleast 2-3 lines in height.

EDIT: You can create your own custom textview(as required by you) by subclassing it.Because UITextView itself is a subclass of UIScrollView.Create a subclass of UITextView's method called - (UIEdgeInsets) contentInset;(make it return UIEdgeInsetsZero).

Good luck.

Master Stroke
  • 5,108
  • 2
  • 26
  • 57
0

Disable the clear button appearing from the right side of the textfield.

Rakitha
  • 894
  • 1
  • 12
  • 25
0

You are using sizeTofit which automatically adjust the rect and font of textview..

Krishna Kumar
  • 1,652
  • 9
  • 17