UIPicker视图的UITextfield问题 [英] UITextfield issue with UIPicker view

查看:34
本文介绍了UIPicker视图的UITextfield问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是视图的图像我有以下问题.我为用户创建了一个样本用户信息表单.他填写了一些细节并提交了.请参见上面的屏幕截图中的第一个子图像.

Here is image of view I have following problem. I created a sample user information form for user. He fills some details and submits. See the first sub image in above screenshot.

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

I am entering first name and last name here, normal keyboard will appear when I switch first name to last name manually by scrolling a view or by using keyboard next button on keyboard.

然后,当单击代码文本字段时,将显示uipickerview/UIActionsheet.请看上一张图片.

Then, when click code textfield, a uipickerview/UIActionsheet will appear. Plase see previous image.

工作正常.当我将一个名字文本字段移至姓氏文本字段,并将姓氏文本字段移至代码文本字段时.

It is working fine. When I move one firstname textfield to last name text field and from lastname to code text field.

问题:我的问题是,假设当前我是姓氏文本字段,即我正在输入我的姓氏,然后在出现问题后单击代码文本字段.看到下面的图片.这是我的问题

Problem : My problem is that, suppose currently I am lastname textfield i.e I am entering my last name and I clicked on code textfield following issue is coming. seen the below image.Here is my problem

因此,这里出现了键盘,而uipickerview/UIactionsheet也出现了,但是在键盘中.我不知道它会来.不仅姓氏代码文本字段从姓氏tp代码文本字段或电子邮件文本字段到代码文本字段...仅当我通过滚动/切换将一个文本字段移至下一个字段时,才会出现相同的问题.如果我使用键盘上的下一个按钮,它正在移动并且正在工作.

So here, keyboard is appearing as well as uipickerview/UIactionsheet is also coming but in behing keyboard. I don't know it is coming. Not only last name to code textfield form first name tp code textfield or email textfield to code textfield...same issue is coming only when I move to one textfield to next field by scrolling/switching. If I use next button from keyboard it is moving and working file.

任何人都可以帮助我解决此问题.

Anybody help me to sort out this problem.

这是我的代码,

@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的方法.

Here is method for 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

again same question, check my solution..! I already posted answer for this. https://stackoverflow.com/a/46903445/8174920

这篇关于UIPicker视图的UITextfield问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆