Make sure that the textFieldShouldReturn function that you wrote in myViewController.m is even called. Set a breakpoint in it, and then run the simulator. Press the back key on the keyboard. If the program does not break, then the function you wrote is not called.
If so, it is because you have not delegated UIResponder instructions to your view controller. Make sure you delegate the responsibilities of the responder to your myViewController class for the UITextField that you are working with.
In the storyboard, you do this by controlling the drag from the UITextField widget to the yellow frame under the scene and selecting โdelegateโ from the pop-up menu that appears.
source share