views:

1110

answers:

5

Hello,

I'm looking for a way to slide the keyboard into view from the right, like what happens in the Contacts application when you edit a note.

My problem is that when I call [someTextView becomeFirstResponder] in viewWillAppear, the keyboard immediatly pops up with no animation. And when I call it in viewDidAppear, the view first slides in from the right (UINavigationController does the sliding), and then the keyboard slides in from the bottom.

Is it possible to have the keyboard slide in from the right, together with the view?

A: 

I think this may be what you're looking for.

http://blog.weareuproar.com/?p=13

Brandon Schlenker
That's an interesting blog post, but alas not what I'm looking for.
Toon Van Acker
A: 

You could try sending the becomeFirstResponder message to the new view controller before you push it onto the stack. For example:

-(void)functionWhereYouPushTheNewViewController {
  yourNewViewController *newVC = [[yourNewViewController alloc] init];
  [newVC.yourTextView becomeFirstResponder];
  [self.navigationController pushViewController:newVC animated:YES];
}

I have found that changing animations on things like they keyboard is pretty tough though, and if you read the Human Interface Guidelines Apple makes it pretty clear that they want certain things to act in certain ways, all the time. There are ways to change the behaviors of certain animations but they often involve undocumented API calls and are grounds for rejection from the app store. It would be a violation of HIG to have pushed views slide up from the bottom, for example.

Hope this helps.

Tim Bowen
Oddly enough, if I call becomeFirstResponder before pushViewController it does nothing. Perhaps because the view hasn't actually been made part of the interface yet. Calling it after pushViewController causes the keyboard to just pop up instantly.If getting the keyboard to behave is as hard as you say (although Apple does it somehow in the Contacts app), then perhaps I should just leave it be.
Toon Van Acker
+6  A: 

All you need to do is tell the text view in question to become the first responder in the -viewDidLoad method of the view controller you are pushing onto the navigation stack:

- (void)viewDidLoad {
    [someTextView becomeFirstResponder];
    [super viewDidLoad];
}

I have tested this and it works. The keyboard slides in from the right along with the view.

titaniumdecoy
If he says it works, it probably works... heh ;)
Jasarien
I have also written a small test using this solution and it works exactly as the Contacts app does when editing a note. +1!
Jasarien
This is the correct answer, although not entirely for my specific case (it put me on the right track though). My text view was inside a table single view cell (due to me wanting the rounded border and being lazy). Apparently, the keyboard doesn't like this. It turned out to be the cause of the keyboard instantly appearing rather than sliding in from the right. Your answer helped me track down the cause of my problem, so thank you!
Toon Van Acker
That'll teach me to be lazy...
Toon Van Acker
You're welcome. :)
titaniumdecoy
A: 

Toon van Acker, you wrote you solved the problem, will you please share the answer with us? I got the exact same problem with a textField inside a table view cell.

Thanks a lot!

Berend
My solution was to not have the text field inside a table view cell. Can't really help you any further, sorry.
Toon Van Acker
+1  A: 

I had the same problem and managed to find this answer: here

Daniel Granger
This is a better answer to my question, but I can sadly not accept it instead of the one I accepted back in July.
Toon Van Acker