开发者

Iphone -ScrollView smearing the view and the text

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];

 NSVa开发者_Python百科lue* 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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜