Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
- [theTextField resignFirstResponder];
- if(theTextField == txtName);
- return YES;
- if(theTextField == txtEmail);
- return YES;
- if(theTextField == txtURL);
- return YES;
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- if (textField == txtName) {
- [txtEmail becomeFirstResponder];
- }
- if (textField == txtEmail) {
- [txtURL becomeFirstResponder];
- }
- if (textField == txtURL) {
- [txtComment becomeFirstResponder];
- }
- }
- - (void)textViewDidBeginEditing:(UITextView *)textView {
- postButton.title = @"Done";
- [postButton setAction:@selector(textViewDidEndEditing)];
- if (self.view.frame.origin.y == 0) {
- CGRect viewrect = self.view.frame;
- CGRect barRect = navBar.frame;
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:0.3];
- NSLog(@"Comment Did Start Editing!");
- viewrect.origin.y -= kOFFSET_FOR_KEYBOARD;
- barRect.origin.y += kOFFSET_FOR_KEYBOARD;
- viewrect.size.height += kOFFSET_FOR_KEYBOARD;
- self.view.frame = viewrect;
- navBar.frame = barRect;
- [UIView commitAnimations];
- }
- }
- - (void)textViewDidEndEditing {
- if (self.view.frame.origin.y < 0) {
- postButton.title = @"Post";
- [postButton setAction:@selector(postComment:)];
- CGRect viewrect = self.view.frame;
- CGRect barRect = navBar.frame;
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:0.3];
- NSLog(@"Comment Did Start Editing!");
- viewrect.origin.y += kOFFSET_FOR_KEYBOARD;
- barRect.origin.y -= kOFFSET_FOR_KEYBOARD;
- viewrect.size.height -= kOFFSET_FOR_KEYBOARD;
- self.view.frame = viewrect;
- navBar.frame = barRect;
- [UIView commitAnimations];
- [txtComment resignFirstResponder];
- }
- }
- - (IBAction)editingDidStart:(id)sender {
- NSLog(@"Editing Did Start");
- }
- - (IBAction)editingDidEnd:(id)sender {
- NSLog(@"Editing Did End");
- }
Add Comment
Please, Sign In to add comment