Datasheet
772
Entering and Saving the Hotel Information
If you find autocorrecting annoying, as I do, you can shut it off programmatically.
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @”Hotel Information”;
UIBarButtonItem *cancelButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@”Cancel”
style:UIBarButtonItemStyleBordered target:self
action:@selector(cancel:)];
self.navigationItem.leftBarButtonItem =
cancelButtonItem;
[cancelButtonItem release];
UIBarButtonItem *saveButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@”Save”
style:UIBarButtonItemStyleDone target:self
action:@selector(save:)];
self.navigationItem.rightBarButtonItem = saveButtonItem;
[saveButtonItem release];
street.text = hotel.street;
state.text = hotel.state;
zip.text = hotel.zip;
name.text = hotel.name;
city.text = hotel.city;
name.autocorrectionType = UITextAutocorrectionTypeNo;
street.autocorrectionType = UITextAutocorrectionTypeNo;
city.autocorrectionType = UITextAutocorrectionTypeNo;
state.autocorrectionType = UITextAutocorrectionTypeNo;
zip.autocorrectionType = UITextAutocorrectionTypeNo;
}
You can also set all the other keyboard traits as well, including what keyboard is being used.
These properties are part of the UITextInputTraits protocol, which defines features that
are associated with keyboard input. To work correctly with the text input management system,
an object must adopt this protocol. The UITextField and UITextView classes already
support this protocol.
Don’t tell me what to do!
If you compile and run this code at this point, it will work, but you still get
two warnings, due to the fact that you haven’t implemented either of the
methods you declared as IBActions to support the contacts buttons.
You’ll do that next.
41_542934-bk07ch01.indd 77241_542934-bk07ch01.indd 772 3/23/10 11:01 PM3/23/10 11:01 PM