質問

私はAccessoryViewsについて学習し、アップルの例をテストしている:<のhref = "http://developer.apple.com/iphone/library/samplecode/KeyboardAccessory/Listings/Classes_ViewController_m.html" のrel = "nofollowをnoreferrer" > 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;
}
役に立ちましたか?

解決

inputAccessoryViewは標準リンゴ仮想キーボードの上まで来て見るためのものです。あなたは、画面上のキーボードが表示されるように許可していない場合は、inputAccessoryViewはどちらか表示されません。

あなただけのカスタムショーにキーボード、およびNOT標準オンスクリーンキーボードを使用する場合は、

は、あなたがinputViewの代わりinputAccessoryViewを使用する必要があります。ここinputViewとinputAccessoryViewの違いを参照してください。 http://developer.apple.com/ iphone /ライブラリ/ドキュメント/ UIKitの/参照/ UITextView_Class /リファレンス/ UITextView.htmlする

他のヒント

あなたが本当に唯一accessoryviewをしたい場合は、あなたがいない高さのビューにinputviewを設定する必要があります。

Xcodeの6には、IOS 8.1シミュレータは、デフォルトでは非表示のキーボードを示しています。 (私はそれが表示されるようにするには、「トグルソフトウェアキーボード」を選択する必要があります。)

私だけaccessoryviewが表示されますので、私は、これを愛しています。

このプログラムで(キーボードトグルオンとオフ、なし却下)

を再現する

私が道

ありがとうございます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top