tags:

views:

71

answers:

0

I'm having a problem wherein when I try to resize the frame when the keyboard shows, in a UITextView, the content from the previous frame remains visible, rendering the result unreadable. I'm wondering if anyone else has encountered this problem?

More background: when the UITextView is rendered, I set its text to the contents of a file. When the user touches the screen and sets off the resize event, the result is two versions of the text on top of one another. Code for resize is below:

- (void)keyboardWasShown:(NSNotification *)aNotification {
    if (!keyboardShown) {
        NSDictionary *info = [aNotification userInfo];

        // Get the size of the keybaord
        //
        NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
        CGSize keyboardSize = [aValue CGRectValue].size;

        // Resize the view
        //
        CGRect viewFrame = [xslView frame];
        viewFrame.size.height -= keyboardSize.height;
        [xslView setFrame:viewFrame];

        // Scroll the view
        // 
        [xslView setContentOffset:CGPointMake(0, 0) animated:YES];

        keyboardShown = YES;
    }
}