UITextField를 선택한 경우 누구나 기본 예제를 사용하여 UIPickerView를 표시 할 수 있습니까?UITextField 선택시 UIPickerView 표시
답변
내가 한 것은 touchesEnded 이벤트를 구현 한 것입니다. 해당 이벤트 내 UITextField에 매개 변수에서 발생하는 경우 I 중 하나를 숨기거나 내가 정확히이 일을 내 블로그에 배치 코드와 모든 것을 가지고있는 UIPickerView
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view]))
{
//Want to show or hide UIPickerView
if(pickerView)
{
submitButton.hidden = !submitButton.hidden;
pickerView.hidden = !pickerView.hidden;
}
}
}
NSTextField있는 위임 방법에있을 것입니다 그렇게 할 수있는 가장 좋은 장소 :
- (BOOL)textShouldBeginEditing:(NSText *)textObject
재정 NO를 반환하는 대신 피커보기를 연상 할 수있는 방법. NO를 반환하면 키보드가 나타나지 않습니다.
을 보여줍니다. 하지만 아래에는 기본적인 개념이 있습니다.
기본적으로이 솔루션은 github의 ActionSheetPicker라는 오픈 소스 프로젝트와 관련되어 있으며 을 UITextFieldDelegate
에 구현합니다. 거기에서 키보드를 닫고 대신 UIPickerView를 제공 할 수 있습니다. 나는이 질문에 얼마 전에 질문을 받았다 알고
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// We are now showing the UIPickerViewer instead
// Close the keypad if it is showing
[self.superview endEditing:YES];
// Function to show the picker view
[self showPickerViewer :array :pickerTitle];
// Return no so that no cursor is shown in the text box
return NO;
}
편집을하지만, 좀 더 최근의 솔루션을 제공하는 것이 필요하다고 생각 : 기본 코드는 여기에 나열됩니다.
댓글을 달았을 때 답변을 업데이트하는 중이었습니다 :) – KVISH
Excellent; 감사! –
- 1. UITextField 및 UIPickerView
- 2. UITextField - 키보드와 UIPickerView 간 전환
- 3. UITextField 표시 문제
- 4. 라디오 선택시 div 표시/숨기기
- 5. Visual Studio 2008의 선택시 키워드 강조 표시
- 6. UIPickerView
- 7. ios uitextfield 및 단추 전환 표시/사라짐
- 8. iPhone OS 구문 강조 표시 UITextField
- 9. 선택시 테이블 전환
- 10. 초기화 UIPickerView
- 11. IPad + UIPickerView
- 12. IB가없는 UIPickerView?
- 13. UIPickerView 연결
- 14. UIPickerView 데이터
- 15. iphone의 UIPickerView
- 16. 랩 UIPickerView?
- 17. UIPickerView 글꼴
- 18. Animating UIPickerView
- 19. UIPickerView 및 NSUserDefaults 문제
- 20. 회원 선택시 IntelliSense 규칙 "
- 21. UITextField autocomplete
- 22. Validate UITextField
- 23. UITextField 포커스
- 24. 아이폰의 UITextField
- 25. UiTextField 이벤트
- 26. UITextField resignFirstResponder
- 27. UITextField 타원
- 28. 의 UITextField
- 29. UITabBarController를 통해 UIPickerView 추가하기
- 30. UIPickerView - 행을 강조 표시 할 때 발생하는 이벤트
나는 이것이 같아야한다고 생각한다 : - (BOOL) textFieldShouldBeginEditing : (UITextField *) textField – Kurt
당신 말이 맞아요. API가 잘못되었습니다. – TechZen