Hi!
I'm learning about AccessoryViews and testing the Apple example: KeyBoardAccessory
I'm trying to show the accessory view avoiding the Keyboard to show, but I can't do it :-(
I'm returning NO in textViewShouldBeginEditing to avoid keyboard and animating the resize of the TextView before return, but nothing happens.
What I'm doing wrong?
- (void)viewWillAppear:(BOOL)animated {
// Make the keyboard appear when the application launches.
[super viewWillAppear:animated];
[textView becomeFirstResponder];
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)aTextView {
NSLog(@"textViewShouldBeginEditing");
/*
You can create the accessory view programmatically (in code), in the same nib file as the view controller's main view, or from a separate nib file. This example illustrates the latter; it means the accessory view is loaded lazily -- only if it is required.
*/
if (textView.inputAccessoryView == nil) {
[[NSBundle mainBundle] loadNibNamed:@"AccessoryView" owner:self options:nil];
// Loading the AccessoryView nib file sets the accessoryView outlet.
textView.inputAccessoryView = accessoryView;
// After setting the accessory view for the text view, we no longer need a reference to the accessory view.
self.accessoryView = nil;
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y, textView.frame.size.width, textView.frame.size.height - 100);
[UIView commitAnimations];
return NO;
}