views:

623

answers:

1

Here's the setup:
I have a textView (txtReply) where the user puts information
I have a UIView that contains a scroll view and some labels, as well as the textView (ChatView)

When the user selects the textView, then it brings the keyboard up. I use 'keyboardWillAppear' to move the 'ChatView' up so that the text view is still visible. I then have a reply button that submits the message, draws it into the ChatView, and calls [textView resignFirstResponder].
However, when I do this, it calls the keyboardWillHide, my view resizes, then the it brings the keyboard back up again. Is there something special you have to do to get the keyboard to stay hidden?

Thanks

A: 

I have a view with four UITextField through which I tab via the 'Next' key on the keyboard. My setup for the keyboard/view animation is as below. My code is for TextFields, but I assume it will work in a similar fashion for TextViews. This is the pragmatic approach.

- (void) viewWillAppear:(BOOL)animated
{
    self.keyboardAnimation = YES;

.
.
.
}

- (void)keyboardWillShow:(NSNotification *)aNotification 
{
    if (self.keyboardAnimation == YES)
    {
        // do the animation
        self.keyboardAnimation = NO;
    }
}

- (void)keyboardWillHide:(NSNotification *)aNotification
{
    if (self.keyboardAnimation == YES)
    {
        // do the animation
    }
}

- (void)doneAction:(id)sender
{
    // finish typing

    self.keyboardAnimation = YES;

    [currentTextField resignFirstResponder];

        // this will remove the "done" button
    self.navigationItem.rightBarButtonItem = nil;
}

- (void)textFieldDidBeginEditing:(UITextField*)textField;
{   
self.currentTextField = textField;
.
.
.
}


- (BOOL)textFieldShouldReturn:(UITextField *)inTextField
{

        // build our own tablist
    switch ([inTextField tag])
    {
        case 100:
        {
            [[self.view viewWithTag:101] becomeFirstResponder];
            break;
        }
        case 101:
        {
            [[self.view viewWithTag:102] becomeFirstResponder];
.
.
.
}
Volker Mohr
Actually it doesn't quite work that way (I had already tried it :) ), however I found out the problem was that changing 'editable' on a UITextView sets the text view to be the first responder.
Philip J