Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on Apr 14, 2013 10:55 AM

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];

}

4 replies
Question marked as Best reply

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];

}

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 ID.