2011-08-15 4 views
0

UIButton이 있고 UIButton의 편집 가능한 UITextField onclick을 개발하려고합니다. 기본적으로 사용자가 단추를 클릭하고 텍스트를 편집하여 나중에 사용할 수 있도록 저장하려고합니다.UIButton 클릭시 UITextfield를 추가하고 편집 가능하게하는 방법

그래서 현재 내가 가진 :

[notes_button addTarget:self action:@selector(editNote) forControlEvents:UIControlEventTouchUpInside]; 

내가 온 클릭의 UITextField 같은 팝업을 얻고위한 editNote 기능에서의 UITextField를 추가하는 방법을 잘 모르겠습니다.

+0

당신은 사용자가 _notes_button_을 누르면 이후의 UITextField가 편집 될 것을 원하십니까? 그 시점에 나타나야합니까? –

+0

사용자가 notes_button을 누르면 uitextfield가 나타나야하며 편집 가능해야합니다. – lifemoveson

답변

1

시도해보십시오. 먼저 viewdidload에서 텍스트 필드를 숨기십시오. 그런 다음 버튼을 누르고 푸십시오. 편집 가능하게 만들고 사용자를 위해 키보드를 팝업하십시오.

//viewDidLoad 

yourTextField.alpha = 0; 
yourTextField.userInteractionEnabled = FALSE; 

-(void)editNote { 

      //fade in text field after button push 
      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDelay:0]; 
      [UIView setAnimationDuration:0.75]; 
      yourTextField.alpha = 1; 

      [UIView commitAnimations]; 

      //make text field editable 
      yourTextField.userInteractionEnabled = TRUE; 

      //pop up keyboard 
      [yourTextField becomeFirstResponder]; 

} 

------- 업데이트 -------- 이제 조금 더 나은 무엇을하려고 설명했다고

. 이 새 View Controller에서 필드 (UITextFields 등)를 사용하여 완전히 새로운 ViewController를 생성해야합니다. 버튼에

당신이 코드를합니다 클릭

TextFieldViewController * vc = [(TextFieldViewController *)[[TextFieldViewController alloc] init] autorelease]; 
[self.navigationController presentModalViewController:vc animated:YES]; 
[vc release]; 

//you will need to create a button on this new ViewController and use this code to dismiss it when done. 

[[self parentViewController] dismissModalViewControllerAnimated:YES]; 
+0

나는 내 질문에 틀을 정확하게 짓지 않았다. 나는 실제로 "리뷰 쓰기"버튼이있는 Yelp와 같은 것을 원합니다. 해당 버튼을 클릭하면 편집 가능한 초안을 저장할 수있는 검토 페이지가 표시됩니다. – lifemoveson

+0

그리고 textviewcontroller 내에서 편집 가능한 텍스트 필드를 사용하여 UITextView를 개발해야합니다. – lifemoveson

+0

예, 버튼과 함께 완료되면보기를 닫을 수 있습니다. "저장"버튼은 정상적으로 작동합니다. 저장 후 닫습니다. – Louie

관련 문제