簡體   English   中英

UIPicker 視圖的 UITextfield 問題

[英]UITextfield issue with UIPicker view

這是我有以下問題的視圖圖像 我為用戶創建了一個示例用戶信息表單。 他填寫了一些詳細信息並提交。 請參閱上面屏幕截圖中的第一個子圖像。

我在這里輸入名字和姓氏,當我通過滾動視圖或使用鍵盤上的鍵盤下一個按鈕手動將名字切換到姓氏時,將出現普通鍵盤。

然后,當單擊代碼文本字段時,將出現一個 uipickerview/UIActionsheet。 請參閱上一張圖片。

它工作正常。 當我將一個名字文本字段移動到姓氏文本字段並從姓氏文本字段移動到代碼文本字段時。

問題:我的問題是,假設目前我是姓氏文本字段,即我正在輸入我的姓氏,然后我點擊了代碼文本字段,問題即將到來。 看到下圖。 這是我的問題

所以在這里,鍵盤出現了,uipickerview/UIactionsheet 也出現了,但在鍵盤中。 我不知道它來了。 不僅姓氏編碼文本字段形式名字 tp 代碼文本字段或電子郵件文本字段編碼文本字段......只有當我通過滾動/切換移動到一個文本字段到下一個字段時才會出現同樣的問題。 如果我使用鍵盤上的下一個按鈕,它正在移動和工作文件。

任何人都可以幫我解決這個問題。

這是我的代碼,

@interface CreateTicketViewController ()

- (void)countryCodeWasSelected:(NSNumber *)selectedIndex element:(id)element;

@end

@implementation CreateTicketViewController


- (IBAction)countryCodeClicked:(id)sender {
    [self removeKeyboard];

    [ActionSheetStringPicker showPickerWithTitle:NSLocalizedString(@"Select CountryCode",nil) rows:_countryArray initialSelection:0 target:self successAction:@selector(countryCodeWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
}


- (void)actionPickerCancelled:(id)sender {
    NSLog(@"Delegate has been informed that ActionSheetPicker was cancelled");
}


- (void)countryCodeWasSelected:(NSNumber *)selectedIndex element:(id)element{
    // self.selectedIndex = [selectedIndex intValue];

    //may have originated from textField or barButtonItem, use an IBOutlet instead of element
    self.codeTextField.text = (_codeArray)[(NSUInteger) [selectedIndex intValue]];
}



#pragma mark - UITextFieldDelegate

- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (textField==_codeTextField) {
        [_codeTextField resignFirstResponder];
         _codeTextField.tintColor = [UIColor clearColor];
        [self removeKeyboard];

        [ActionSheetStringPicker showPickerWithTitle:NSLocalizedString(@"Select CountryCode",nil) rows:_countryArray initialSelection:0 target:self successAction:@selector(countryCodeWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:self.view];
         //return NO;
    }

這是 removeKeyboard 的方法。

UIToolbar *toolBar= [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    UIBarButtonItem *removeBtn=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStylePlain  target:self action:@selector(removeKeyBoard)];


-(void)removeKeyboard{
    [_emailTextField resignFirstResponder];
   // [_mobileTextField resignFirstResponder];
  //  [_msgTextField resignFirstResponder];
    [_subjectTextField resignFirstResponder];
    [_firstNameTextField resignFirstResponder];


}

同樣的問題,檢查我的解決方案..! 我已經為此發布了答案。 https://stackoverflow.com/a/46903445/8174920

你必須這樣做:

_codeTextField.inputView = YOURPICKER

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM