내보기에 textField 및 버튼이 있고 텍스트 필드가 비어 있으면 버튼을 클릭 할 수 없으므로 원하지 않습니다. 사용자가 텍스트 필드에 텍스트를 입력하면 버튼이 클릭 할 수 있습니다. 어떻게해야합니까? 고맙습니다.UITextField 및 UIButton
0
A
답변
1
, 당신은 설정할 수 있습니다 : 당신의 편집에 그런
[textField addTarget:self action:@selector(editing:) forControlEvents:UIControlEventAllEditingEvents];
:이 :
-(void)editing:(UITextField *)sender {
myButton.enabled = ![sender.text isEqualToString:@""];
}
1
텍스트 필드의 변경 내용을 듣습니다. 텍스트가 변경되면 텍스트가 있는지 여부에 따라 버튼의 enabled
속성을 업데이트하십시오. 물론 처음부터 버튼의 상태도 설정해야합니다.
// Setup the text field change listener (this can be done in IB if appropriate)
// Put this in viewDidLoad if not using IB.
UITextField *myTextField = ... // a reference to the text field
[myTextField addTarget:self action:@selector(textFieldChangedAction:) forControlEvents:UIControlEventEditingChanged];
// Initialize the button's state (put this in viewDidLoad)
myButton.enabled = myTextField.text.length > 0;
// The method called as the text changes in the text field
- (void)textFieldChangedAction:(UITextField *)sender {
myButton.enabled = sender.text.length > 0;
}
0
당신이 원하는 경우에, 당신이 할 수있는 "숨기기"버튼을 설정하여 버튼의 알파 값을 0으로 설정하고 텍스트 필드가 적어도 하나 이상의 문자 인 경우 버튼의 알파 값을 1로 설정하여 버튼을 "표시"합니다. 나는 개념적으로이 일을하기가 쉽고 사용자에게 매우보기 좋다고 생각한다.
0
textfielddidbeginediting 대의원에 그런 자기 에 textfield.delegate
그리고 거기 ( 확인이 텍스트 필드가이다는 @ "" 다음 버튼 사용 버튼 그렇지
해제) 설정 하나 더 있습니다. , 유
Textdidchangecharacters
그리고 버튼의 viewDidLoad에 처음 상태관련 문제
- 1. 사용자 정의 UITextField/UIButton
- 2. UITextField 내부 UIButton
- 3. 추가 및 조정 uitextfield
- 4. MFMailComposeViewController 및 UITextField 범주
- 5. UITableViewCell 및 UITextField
- 6. UITcrollVew의 UITextField 및 UILabel
- 7. UITextField clearButtonMode 및 UIPicker
- 8. UITextField 및 흥미로운 프로그램
- 9. UITextField 및 UIPickerView
- 10. UIScrollView 배치로 인해 UIButton 및 UITextField가 unclickable입니까?
- 11. 여러 UITextField 및 ViewControllers와 함께 inputAccessoryView 사용
- 12. Animate UITextField
- 13. UIButton 표시 및 사라짐
- 14. 가있는 UIButton 및 IBAction를
- 15. UIButton 및 UITapGestureRecognizer가있는 UIScrollView
- 16. UIFocusGuide UITableView 및 UIButton
- 17. UIButton 및 이미지
- 18. UITapGestureRecognizer 및 UIButton = EXC_BAD_ACCESS
- 19. UIButton setBackgroundImage 및 viewWillAppear
- 20. UIButton 및 UIControlEventState 문제
- 21. UIButton 및 UIPicker
- 22. UITextField 기준 위치 계산
- 23. iOS 및 Sparrow Framework의 UITextField
- 24. UITextView 및 UITextField 텍스트 흐리게지고있다
- 25. UITextField 편집 및 배열에 추가
- 26. UITextField 및 UILabel 업데이트 문제
- 27. 자르기 배경 및 내용 uitextfield
- 28. iOS UITextField 및 NSTimer Oddity
- 29. 의 UITextField 및 웹 서비스
- 30. UitextField 및 UIWebView 상호 작용?
이 작동하지 않도록해야한다에서 사용할 수 위임 감사합니다. – jxdwinter