views:

82

answers:

1

Hi,

I registerd for the keyboard show event, and implemented the method like this :

-(void) KeyboardDidShow:(NSNotification*)notif{

 if (KeyboardVisible)
 {
  NSLog(@"Keyboard is already visible");
  return;
 }

 NSDictionary* info = [notif userInfo];

 NSValue* value = [info objectForKey:UIKeyboardBoundsUserInfoKey];
 CGSize keyboardSize = [value CGRectValue].size;

 CGRect ViewFrame = self.view.frame;
 ViewFrame.size.height-=keyboardSize.height;

 scrollView.frame = ViewFrame;
 KeyboardVisible = YES; 

}

Within my view I have 2 textViews. The problem I have is : When I put the cursor within the textView and the keyboard pops, If I play with the view cursor up and down all text is getting smeared and it looks like the 2 textviews mix. Is there something wrong with this code ? (It is actually taken from a book i'm reading). Worth mentioning is that initially the view was implemented without scrolling, and then scrolling abilities were added using the "Embed objects in Scroll View" command.

A: 

Is self.view the same as scrollView? You should probably be using the scroll view's frame as the starting point of your change:

CGRect ViewFrame = scrollView.frame;

instead of

CGRect ViewFrame = self.view.frame;

Also double check your xib file to ensure that both of your text views are subviews of the scroll view and not sibling views. Perhaps you only embedded one of the text views?

Jason Foreman
Nope man. All the text view are indeed sub views of the scroll view, which is a subview of the main view.Tried doing what u suggested(with the scroll view frame) to no avail.Other suggestions ?
Idan