iOS2012. 10. 4. 11:23

UITextField가 존재하는 뷰의 viewWillDisappear 또는 viewDidDisappear 메소드에서

[self.view endEditing:YES];

을 호출하면 해당 키보드가 내려간다.


resignFirstResponder도 물론 가능하다. 하지만 UITextField 객체가 멤버 변수로 선언 되어 있지 않을 경우

유용할 듯..

Posted by 다오나무
iOS2012. 9. 12. 16:26


- (void)viewDidLoad{   
      commentTxtView
.text = @"Comment";
      commentTxtView
.textColor = [UIColor lightGrayColor];
}
- (BOOL) textViewShouldBeginEditing:(UITextView *)textView
{
     if(commentTxtView.text.length > 0 && commentTxtView.textColor == [UIColor blackColor])
    	 return YES;
 
     commentTxtView.text = @"";
     commentTxtView
.textColor = [UIColor blackColor];
     
return YES;
}


-(void) textViewDidChange:(UITextView *)textView
{
if(commentTxtView.text.length == 0){
    commentTxtView
.textColor = [UIColor lightGrayColor];
    commentTxtView
.text = @"Comment";
   
[commentTxtView resignFirstResponder];
}
}


Posted by 다오나무