Dismissing the keyboard in the iPhone 101 Tutorial

Is anyone able to dismiss the keyboard in creating the app in the iPhone 101 tutorial? I have literally copied and pasted the code from the View Controller implementation and interface files, and the keyboard still doesn't go away when I click "Done." In fact, if I place a breakpoint in the textFieldShouldReturn method, the app doesn't stop and the debugger never breaks. It's like the UITextField never fires off textFieldShouldReturn. I've even tried to set the view as the delegate, as other threads have suggested:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
textField.delegate = self;
changeGreeting, though, works just fine. This is in the simulator using Beta 5, by the way. I haven't tried it on a device just yet.
Here's my controller's interface code:
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController <UITextFieldDelegate> {
IBOutlet UITextField *textField;
IBOutlet UILabel *label;
NSString *string;
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UILabel *label;
@property (nonatomic, copy) NSString *string;
- (IBAction)changeGreeting:(id)sender;
@end
And here's my controller's implementation code:
#import "MyViewController.h"
@implementation MyViewController
@synthesize textField;
@synthesize label;
@synthesize string;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
textField.delegate = self;
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
return self;
- (IBAction)changeGreeting:(id)sender {
self.string = textField.text;
NSString *nameString = string;
if ([nameString length] == 0) {
nameString = @"World";
NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!",
nameString];
label.text = greeting;
[greeting release];
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == textField) {
[textField resignFirstResponder];
return YES;
Any help would be appreciated.

Thank you akollegger! I found that I needed to make sure you have all the appropriate connections. In the "Configuring the View" page (http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone 101/Articles/05_ConfiguringView.html), I found that I had missed the following line in the "Making Connections" section:
Connect the label and textField outlets. Control click File’s Owner to display a translucent panel that shows all the available outlets and actions, then drag from the circle to the right of the list to the destination to make the connection.
The picture shows you how to connect the label, but the text tells you that you need to connect both the label and the textField outlets.
When I went back and looked at the outlets for MyViewController (double click on MyViewController.xib, Ctr-click on "File's Owner"), I noticed that I had an outlook connection from "label" to a Label and mousing over it highlighted the label in the View. It took a while to realize that I was missing the connection between "textField" and the UITextField in the View. Without that connection, there is no routing of the textFieldShouldReturn event from the keyboard.
To fix the problem, drag from the open circle next to "textField" to the UITextField in the View. Voila!
Hope this helps!
- Peter

Similar Messages

  • Is it possible to use the Apple wireless keyboard with the iPhone 6? Will the Magic Mouse work with iMovie on iPhone6 Plus?

    iPhone 6 page says that iMovie is a (free) application available for iPhone 6. When I use it on the desktop I need a mouse. Should I expect all controls to be touch-sensitive, or is it possible to use the wireless Magic Mouse? Similarly, if I want to type an email or a long document, is it possible to use the Mac wireless keyboard to enter text? With the iPhone 6 Plus taking over for laptops (phablet), it seems to me that input tools are relevant. Maybe what I'm asking is whether the iPhone6 (OS8) has drivers for these devices. Please advise.

    Apps that are designed for iOS devices such as the iOS version of iMovie are intended to be used entirely by touch. It's worth noting that iMovie for iOS is not absolutely identical to iMovie for Mac OS.

  • How do I move the alphabet keyboard on my iphone 5 iOS 8?  It is stuck on my DropBox app., I can't slide the keyboard down.

    As I open my DropBox App the keybioard appears adn prevents me from entering my password to access my DropBox content.  How do I move the alphabet keyboard on my iphone 5 iOS 8?  It is stuck on my DropBox app and I can't slide the keyboard down.

    Well, as an AT&T user, APN settings are governed by the carrier file, and we cannot change them. I've not used the configuration utility, so I'm "dumber" than you! See if this support document will help you out any. http://support.apple.com/kb/HT4839.

  • When I open the settings and messages of the iPhone 4s I get stuck in a white screen, what should I do? the keyboard to open there is minute, I can not open the settings in any way.

    when I open the settings and messages of the iPhone 4s I get stuck in a white screen, what should I do? the keyboard to open there is minute, I can not open the settings in any way.

    Try a reset: Simultaneously hold down the Home and On buttons until the device shuts down. Ignore the off slider if it appears. Once shut down is complete, if it doesn't restart on it own, turn the device back on using the On button. In some cases it also helps to double click the Home button and close all apps from the tray BEFORE doing the reset.

  • Does the iphone 4s have the split keyboard or can you only do that on the ipad

    can you get the split keyboard on the iphone 4s or is that only on ipads?

    A friend has an iPhone 4s and he can split the keyboard on it, but it doesn't work on my 4s.  I'm not sure why, unless it's because his 4s is newer than mine.

  • Does the Iphone 4s have an AZERTY-keyboard in Belgium?

    Does the Iphone 4S have an AZERTY-keyboard in Belgium?

    If you select French under Settings>General>Keyboard>International Keyboards, you can select: AZERTY, QWERTY or QWERTZ, with AZERTY being default.

  • Will the iPhone 5 have a keyboard

    I would personal switch to iPhone from droid if it had an keyboard

    If it's really that necessary: http://www.amazon.com/Wireless-Bluetooth-Sliding-Keyboard-Rubberized/dp/B0052CHO S2/ref=sr_1_1?ie=UTF8&qid=1324589869&sr=8-1
    It's a bluetooth keyboard, so just setup the keyboard in Settings. It should charge via USB. Works with iPhone 4 and 4S.
    I made the switch from a Droid 1 to the iPhone. It felt weird not having a keyboard but now it's just natural.

  • Bottom row of the keyboard is not working in a vertical orientation on the iPhone 3Gs. the "slide to unlock" and all keys on the calculator on both orientation works fine. I can use the keyboard on horizontal orientation.

    Bottom row of the keyboard is not working in a vertical orientation on the iPhone 3Gs. the "slide to unlock" and all keys on the calculator on both orientation works fine. I can use the keyboard on horizontal orientation. The tabs on bottom of all apps also work fine.
    I have already tried holding down the power button and home button for 10 seconds, but no difference.

    I've had this problem on and off for the last few weeks (around, but not directly related, to upgrade to 6.1...can't remember if was before or after)....I'm very convinced it's a software problem (as there have been times when the bottom row works perfectly, without any need to "press" differently or anything).
    However, it seems to be a rather resilient software issue, as a full restore does not consistently fix it, and it applies to more than just the keyboard; if I open a drawing app, there's definitely a row (about 4mm up from the edge of the screen closest to home button) where I cannot draw.
    It's happened 4 times now.  Originally it went away with a restore from backup, then worked for 2 more days.  The second and third times, it went away with a full restore (although I did two full restores in between those two restores that did nothing, so restore didn't consistently fix it)....and it seemed to return in the most random of circumstances. 
    I paid very close attention to what apps I was using the last time it was working so that I could spot which app, if any, might be causing the issue.  I deleted several apps, I stopped using the games and many other apps.   I only used three apps between it working fine and starting up as a problem again: mail, safari and messages.
    I was convinced it was mail, as it happened this morning when I picked up my phone off the bedside table to respond to a new email.  It was working when I went to bed.  I picked up the phone when it buzzed, hit the email app, hit reply and started to type....**** bottom row wasn't working again.
    However, tonight I did 2 things....one of them worked because it went back to normal (sorry, I don't know which as I was exasperated and trying a number of things). 
    The two things I did between a broken keyboard and a working keyboard were:
    1) adding a second keyboard (English(Canada)), changing to this keyboard, and changing back
    2) disabling Siri...and then turning it back on...and then disabling Siri's "Raise to Speak"
    In retrospect, I wonder if it actually was the "Raise to Speak" that was putting the phone into a weird state, and might explain why the phone would just "suddenly" start behaving strangely when I picked it up.  Of note, the "raise to speak" hasn't actually triggered Siri to come on in months anyway.
    Regardless, the keyboard is back to normal now...and I'm just going to leave "Raise to Speak" off.  I've put the keyboard back to just "English" with no alternates and Siri remains on otherwise without issue.

  • Hello! Ever since I upgraded my iPhone 5s to IOS 7.1, I am unable to access the iPhone Keyboard if I access contacts the recent calls tab. I am also unable to access the keyboard if I want to search for a contact as long as I went through the recent calls

    Hello! Ever since I upgraded my iPhone 5s to IOS 7.1, I am unable to access the iPhone Keyboard if I access contacts using the recent calls tab. I am also unable to access the keyboard if I want to search for a contact as long as I went through the recent calls tab. Has anyone a fix for this problem? If you want to try it out, do the following?
    Dial a number from your iPhone Keypad. After cutting the call, try to save the number you just dialled to your contacts by choosing the new contact option. You will see that you will not be able to key in the name of your new contact.

    Works fine for me.
    Try a reset: Simultaneously hold down the Home and On buttons until the device shuts down. Ignore the off slider if it appears. Once shut down is complete, if it doesn't restart on it own, turn the device back on using the On button. In some cases it also helps to double click the Home button and close all apps BEFORE doing the reset.

  • Does the iPhone have the option of having a standard telephone type keyboard instead of the normal comp type

    Does the iPhone have the option of having a standard telephone type keyboard instead of the normal comp type

    phone icon/keyboard (at the bottom of the page )

  • Why does the iPhone Keyboard have a reversed period and comma from the normal keyboard?

    Why does the iPhone Keyboard have a reversed period and comma from the normal keyboard?

    MacinNW_Brent wrote:
    I don't mean to drive a Marine crazy, but there is no such thing as a standard keyboard. Especially tiny ones. Looks at a phone key pad, and then look at a calulator keypad. It is flipped top to bottom.
    JajLvr, if it drives you crasy, then get a BT keyboard.
    Brent
    Agreed.  Even the iPhone has multiple built-in keyboards to choose from.

  • I removed my English keyboard and locked the iPhone in iOS 8 and now I have the iPhone locked on Arabic keyboad

    I removed my English keyboard and locked the iPhone and now the iPhone locked on Arabic keyboard

    Hi Eliasaa,
    You may need to try the directions for changing your keyboard language found in the following article:
    iOS: Using international keyboards
    http://support.apple.com/kb/HT4509
    If this does not resolve your issue, you may need to follow the instructions in this article:
    iOS: Forgot passcode or device disabled
    http://support.apple.com/kb/ht1212
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • When will Apple do REAL soft "international" keyboards on the iPhone?

    Being a Swedish local, remembering the keynote with Steve Jobs making a big issue of using "soft keyboards" for international characters on the iPhone made my brain over-heat with disappointment when I finally got my iPhone 3G and entered "Swedish" under the keyboard settings hoping that a Swedish keyboard layout would appear on the iPhone's soft keyboard.
    There is no Swedish (and possibly no other "international") keyboard on the iPhone although the settings are there. All there is is a possibility to enter "international" characters through an awkward point-hold-and-drag mechanism! These characters are being used all the time not only on those rare occations you need to spell out "Motörhead" correctly. What if you needed to click-hold-and-drag everytime you wanted to type an "a"?
    Apple have had a few designs through the years that never should have left the office (remember the hockey puck mouse?) and this US-ASCII keyboard layout for "international" keyboards is one of the more ignorant ones - even more so since the facilities for making a proper layout is there.
    (Another bug is the Map application assuming that the USA is the correct country for contacts in the address book where no country has been entered, instead of - for instance - using the country used for the keyboard settings as default country where none is explicitly entered or the country where the iPhone was activated?

    i send this to apple as feedback under under enhancement request in case anyone is bored of typing:
    Hi,
    I recently signed a contract with vodafone Greece for 46 € plan (one of the more expensive from the countries that the iPhone is available) in order to get an iPhone 3G 16GB for 430 € (also one of the highest prices of iPhone with a contract) only to find out that there is no Greek Keyboard. This is unacceptable. I don't care for which other countries you have made keyboard or not (although you make sure to rub it in my face) but the essence of the iphone is that it is a tool to have with you all the time and if the is no ability to right in your native language it is rendered useless. The think that is more frustrating is that those who bought the iPhone from abroad (at 1/4 of the price) and jailbroke it have a Greek keyboard, made by Greek hackers/programmers.
    Today comes, as i am told the 2.1 firmware update and i sincerely hope that ithas the Greek keyboard in it otherwise my (and many other i spoke with that bought the iPhone due to its features and not due to the Apple brand) loyalty to the Apple brand (which is already in bad shape due to the Greek retailer Rainbow) is going to be in jeopardy.
    please fix this
    thank you

  • How are the keyboard cases for the iPhone 4?

    I've been looking around, and it appalls me that they have physical keyboards for the iPhone 4. After looking into it more, I now have a bit of Droid envy. -_-
    Before purchasing, I want to see if I can get first hand reviews on it... I found one cheap, on eBay, http://cgi.ebay.com/130490507671, but before I spring on it, I'd like to know more about them. Any help would be appreciated.

    There is no YouTube app included with iOS anymore.
    You can play most YouTube videos via mobile Safari.

  • Can you force the keyboard to appear on the iphone?

    I was booking some tickets on the web on my my iphone but when it came to completing the date the keyboard disappeared, which made the booking impossible. Is there any way you can force the keyboard to appear?
    Roggs

    Yeah, but there was a data field - for the date, which you have to type in. There was something there the iphone didn't like - no problem when I did it on my laptop.
    Curious.

Maybe you are looking for

  • What's wrong with my Final Cut Pro 7.03?

    What's wrong with my Final Cut Pro 7.03? I have just started up a new project. Every time I try to ad a clip in top of each other a "general error" shows up. The sequence viewer turned red and it displays that I have to close and reopen the window to

  • Help adding a PC to my Mac Airport Network

    A PC as just inflicted itself into our office and we cannot figure out how to get it connected to our existing (all mac) Airport Network. We know zip about PC's. Can someone point us in the direction of a step by step how to guide or tutorial on how

  • LC (Letter of Credit) Processing

    Dear Sirs, I have created a LC using VX11n and assigned the LC number to a Sales order. But, I am not able to see the reduction in LC Value / utilization in the LC report - VXA2. Can anyone suggests how LC is consumed and where can I see the report o

  • Problem in deleting the user

    when iam trying to delete the user from subone directory server it is giving the following exception Insufficient 'delete' privilege to delete the entry how to set the privileges in sunone directory server.please send as it is very urgent for me

  • PDFMaker rasterizes a Vector EMF file

    Greetings!   I use PDFMaker add-in of Adobe Acrobat Pro (11.0.10) with Word 2013 to PDF a document, which contains a vector EMF file.   After conversion I see that original vector image is rasterized completely. If I either save the same source Word