私は、AccessoryViews について学習し、Apple の例をテストしています: KeyBoardAccessory
キーボードを表示せずにアクセサリ ビューを表示しようとしていますが、表示できません :-(
キーボードを避けるために textViewShouldBeginEditing で NO を返し、戻る前に TextView のサイズ変更をアニメーション化していますが、何も起こりません。
私が間違っていることは何ですか?
- (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;
}