0

UItextField の編集が開始されて popover を表示する必要があるときに、誰かが私を助けることができますか?

このプログラミングは初めてです

4

3 に答える 3

0
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    [self showPopOverController];
}
- (void)showPopOverController
{
    self.imgPicker = [[UIImagePickerController alloc] init];
    self.imgPicker.delegate = self;
    self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    _popover = [[UIPopoverController alloc] initWithContentViewController:self.imgPicker];
    [_popover setDelegate:self];
    [_popover presentPopoverFromRect:self.txtField.frame  inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

.h ファイルで宣言する必要がある場所

 UIPopoverController *_popover;
 @property (strong, nonatomic) IBOutlet UITextField *txtField;
 @property (nonatomic, retain) UIImagePickerController *imgPicker;

これはiPadでのみ機能します

于 2013-02-22T04:48:53.423 に答える
0

テキストフィールドのデリゲートメソッドの1つを使用して、テキストフィールドの編集が開始されるとすぐにポップオーバーを表示できます

- (void)textFieldDidBeginEditing:(UITextField *)textField
 {
   [self showPopOver];
 }

注:- showPoperOver はカスタム メソッドです。

また

通知用のオブザーバーに通知できます

UITextFieldTextDidBeginEditingNotification
于 2013-02-22T04:39:35.983 に答える
0

UITextFieldデリゲートを自分自身に設定するがあることを確認してください。

[textField setDelegate : self];

次に、デリゲートを使用します

- (void)textFieldDidBeginEditing:(UITextField *)textField
 {
   // call the method where u r making ur popover
 }

このデリゲートは、 で書き込みを開始すると呼び出されますUITextField

于 2013-02-22T04:44:54.997 に答える