I try to repeat example into First Steps manual, but i can't understand how to hide keyboard when you press the button Done.
here is my code in "MyViewController.h"
Quote:
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController {
UITextField *textField;
UILabel *label;
NSString *string;
}
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *string;
- (IBAction)changeGreeting:(id)sender;
@end
|
and "MyViewController.m"
Quote:
#import "MyViewController.h"
@implementation MyViewController
@synthesize textField;
@synthesize label;
@synthesize string;
- (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 *)Done {
[Done resignFirstResponder];
return YES;
}
|
where is mistake ? keyboard doesn't hide.