2013-02-22 95 views

回答

0

通知觀察者看你有一個UITextField設置代表自我。

[textField setDelegate : self]; 

然後使用委託

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

當你開始在UITextField寫這個委託調用。

+0

我們可以在iphone中使用popover – Sindu 2013-02-22 05:25:39

+0

no popover是隻爲ipad – Kasaname 2013-02-22 05:26:14

+0

,但你總是可以創建自定義popover使用視圖和加載表中的意見 – Kasaname 2013-02-22 05:26:47

0

您可以使用文本框的委託方法之一,儘快顯示您的酥料餅的文本字段開始編輯

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

注: - showPoperOver是一個自定義的方法。

OR

您可以通知

UITextFieldTextDidBeginEditingNotification 
+0

u能張貼showPopOver – Sindu 2013-02-22 04:45:45

+0

如果你想顯示UIPopoverController的方法,那麼你可以按照上面提到的Manohar回答 – 2013-02-22 04:51:52

+0

thanQ,它的工作方式是ipad而不是iphone – Sindu 2013-02-22 05:03:24

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的

+0

而不是ImagePicker製作您自己的ContentViewController。 – 2013-02-22 04:51:20

+0

ThanQ幫助我。但它不適用於iphone – Sindu 2013-02-22 05:02:48

+0

@prathyusha:我看到你以前的問題,我知道你的實際需求是什麼。 – 2013-02-22 05:04:03