我可以点击屏幕上的其中一个文本框,然后会出现一个数字键盘。我有另一个UITextField,它在点击时显示UIPickerView(它在UIView中)。
我有这个代码,当我点击屏幕上的任何地方时,就像它应该解雇数字键盘一样,但它不会忽略我在UIView里面的PickerView ......
//hides keyboard when another part of layout was touched
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
[super touchesBegan:touches withEvent:event];
}
编辑: 我有这个作为显示选择器视图的代码。它确实显示了它,但我对此并不满意,但......我再次为无知感到抱歉。我一直在阅读,谷歌搜索和尽我所能。到目前为止,我只是被困在一些事情上......
//Show Picker Wheel
- (IBAction)showPickerWheel:(id)sender {
//_pickerViewContainer.frame = CGRectMake(0, 290, 320, 192);
// _mulchDepth.inputView = UIView.new;
//self.mulchInches.delegate = self;
//self.mulchInches.dataSource = self;
//[self.mulchInches reloadAllComponents];
//This line hides the default keyboard
[sender resignFirstResponder];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
CGAffineTransform transfrom = CGAffineTransformMakeTranslation(0, 20);
_pickerViewContainer.transform = transfrom;
_pickerViewContainer.alpha = 1;
[UIView commitAnimations];
}