Guest User

Untitled

a guest
May 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
  2. [theTextField resignFirstResponder];
  3. if(theTextField == txtName);
  4. return YES;
  5. if(theTextField == txtEmail);
  6. return YES;
  7. if(theTextField == txtURL);
  8. return YES;
  9. }
  10. - (void)textFieldDidEndEditing:(UITextField *)textField {
  11. if (textField == txtName) {
  12. [txtEmail becomeFirstResponder];
  13. }
  14. if (textField == txtEmail) {
  15. [txtURL becomeFirstResponder];
  16. }
  17. if (textField == txtURL) {
  18. [txtComment becomeFirstResponder];
  19. }
  20. }
  21. - (void)textViewDidBeginEditing:(UITextView *)textView {
  22. postButton.title = @"Done";
  23. [postButton setAction:@selector(textViewDidEndEditing)];
  24. if (self.view.frame.origin.y == 0) {
  25. CGRect viewrect = self.view.frame;
  26. CGRect barRect = navBar.frame;
  27. [UIView beginAnimations:nil context:NULL];
  28. [UIView setAnimationDuration:0.3];
  29. NSLog(@"Comment Did Start Editing!");
  30. viewrect.origin.y -= kOFFSET_FOR_KEYBOARD;
  31. barRect.origin.y += kOFFSET_FOR_KEYBOARD;
  32. viewrect.size.height += kOFFSET_FOR_KEYBOARD;
  33. self.view.frame = viewrect;
  34. navBar.frame = barRect;
  35. [UIView commitAnimations];
  36. }
  37. }
  38. - (void)textViewDidEndEditing {
  39. if (self.view.frame.origin.y < 0) {
  40. postButton.title = @"Post";
  41. [postButton setAction:@selector(postComment:)];
  42. CGRect viewrect = self.view.frame;
  43. CGRect barRect = navBar.frame;
  44. [UIView beginAnimations:nil context:NULL];
  45. [UIView setAnimationDuration:0.3];
  46. NSLog(@"Comment Did Start Editing!");
  47. viewrect.origin.y += kOFFSET_FOR_KEYBOARD;
  48. barRect.origin.y -= kOFFSET_FOR_KEYBOARD;
  49. viewrect.size.height -= kOFFSET_FOR_KEYBOARD;
  50. self.view.frame = viewrect;
  51. navBar.frame = barRect;
  52. [UIView commitAnimations];
  53. [txtComment resignFirstResponder];
  54. }
  55. }
  56. - (IBAction)editingDidStart:(id)sender {
  57. NSLog(@"Editing Did Start");
  58. }
  59. - (IBAction)editingDidEnd:(id)sender {
  60. NSLog(@"Editing Did End");
  61. }
Add Comment
Please, Sign In to add comment