is it possible to give an action for TextFiled?

hi.........Every one.


Now i want to add action with TextField.
just touch on TextField then go to SecondViewController


1 View Controller contain 1 TextField .
then click on Textfield ....
Display 2 ViewController.


Please provide any information about this ...


Thanks Inadvacne:)
Sriaknth

iPhone 5, Mac OS X (10.7.5), XCode 4.6

Posted on Apr 13, 2013 2:14 AM

Reply
4 replies

Apr 14, 2013 10:55 AM in response to Srikanth from Tenali

Assuming the storyboard contains a modal segue with identifier ShowAnotherView from the first view controller to the second, this is one way to do it.


In the first view controller, an IBAction on the textfield. You must hook event TouchDown not TouchUpInside, or the default keyboard handing will interfere.

- (IBAction)theTextField_TouchDown:(id)sender {

[selfperformSegueWithIdentifier:@"ShowAnotherView"sender:self];

}


In the second view controller, some way to close the second view controller and return to the first.

- (IBAction)closeButton_TouchUpInside:(id)sender {

[selfdismissViewControllerAnimated:YEScompletion:nil];

}

Apr 15, 2013 7:56 PM in response to Srikanth from Tenali

AFAIK a segue can only be used in the context of a storyboard. After all, the underlying class name is UIStoryboardSegue.


If your view controller is in a NIB rather than storyboard, handle the textfield's Touch Down event by programmatically instantiating and presenting it.


- (IBAction)theTextField_TouchDown:(id)sender {

AnotherViewController *anotherViewController = [[AnotherViewControlleralloc] initWithNibName:@"AnotherViewController"bundle:nil];

[selfpresentViewController:anotherViewController animated:YEScompletion:nil];

}

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

is it possible to give an action for TextFiled?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.