UIPicker 视图的 UITextfield 问题

UITextfield issue with UIPicker view

Here is image of view 我有以下问题。 我为用户创建了一个示例用户信息表。他填写了一些细节并提交。请参阅上面屏幕截图中的第一个子图像。

我在这里输入名字和姓氏,当我通过滚动视图或使用键盘上的键盘下一个按钮手动将名字切换为姓氏时,将出现普通键盘。

然后,当点击代码文本框时,会出现一个uipickerview/UIActionsheet。请看上一张图。

它工作正常。当我将一个名字文本字段移动到姓氏文本字段以及从姓氏移动到代码文本字段时。

问题:我的问题是,假设目前我是姓氏文本字段,即我正在输入我的姓氏,然后我点击了代码文本字段,问题即将出现。看到下图了。Here is my problem

所以在这里,键盘出现了,uipickerview/UIactionsheet 也出现了,但是在键盘后面。我不知道它来了。 不仅姓氏编码文本字段形成名字 tp 代码文本字段或电子邮件文本字段编码文本字段...只有当我通过 scrolling/switching 将一个文本字段移动到下一个字段时才会出现同样的问题。如果我使用键盘上的下一步按钮,它正在移动和工作文件。

谁能帮我解决这个问题。

这是我的代码,

@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;
    }

这是移除键盘的方法。

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];


}

你必须这样做:

_codeTextField.inputView = YOURPICKER

同样的问题,检查我的解决方案..!我已经为此发布了答案。