无法在键盘上隐藏完成条

时间:2018-04-12 11:31:06

标签: ios objective-c xcode uitextfield

我为文本字段分配了数字键盘。我不想在键盘上或键盘内显示任何按钮栏,但我无法隐藏栏。

我正在尝试删除此栏:

https://us.v-cdn.net/5019960/uploads/editor/hc/uhkppb94cj1o.jpg

我试图做的是:

public class Element {
    public static final String CSV_FILE_URL = "http://www.google.com/File.csv"; //Actual URl not published

    public static void main(String[] args) throws IOException {
        URL url = new URL(CSV_FILE_URL);
        Scanner input =
                new Scanner(url.openConnection().getInputStream());}
    int number ;
    String symbol;
    String name;
    int group;
    int period;
    double weight;

XCode版本:9.3(9E145)

2 个答案:

答案 0 :(得分:0)

- (void)textFieldDidBeginEditing:(UITextField*)textField{
   if (textField != self.yourTextField){
      UITextInputAssistantItem* item = [textField inputAssistantItem];
      item.leadingBarButtonGroups = @[];
      item.trailingBarButtonGroups = @[];
   }else{
      textField.inputAccessoryView = nil;
   }
}

答案 1 :(得分:0)

试试这个:

_txtAge.inputAccessoryView = nil;

完整代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    _txtAge.delegate=self;
    _txtAge.inputAccessoryView = nil;
    [_txtAge becomeFirstResponder];
    _txtAge.autocorrectionType = UITextAutocorrectionTypeNo;
}

// or try this

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {

  if (textField == _txtAge) {
    _txtAge.inputAccessoryView = nil;
  } 

  return true;
}

// or try this

- (void)textFieldDidBeginEditing:(UITextField *)textField {
  if (textField == _txtAge) {
    _txtAge.inputAccessoryView = nil;
  } 
}