1. url은 지운다.
2. RT를 지운다.
3. #의 단락을 지운다.
4. @의 단락.
1. url은 지운다.
2. RT를 지운다.
3. #의 단락을 지운다.
4. @의 단락.
슬슬 노트북으로 다이전하고 전기세를 아끼자 ㅋ
소스..
This section shows project code that inserts a row in a table view. Instead of using the insertion control as the trigger for inserting a row, it uses an Add button (visually a plus sign) in the navigation bar above the table view. This code also is based on the navigation controller and view controller architecture. In its loadView method implementation, the view controller assigns the Add button as the right-side item of the navigation bar using the code shown in Listing 7-4.
Listing 7-4 Adding an Add button to the navigation bar
addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItem:)];
self.navigationItem.rightBarButtonItem = addButton;
Note that the view controller sets the control states for the title as well as the action selector and the target object. When the user taps the Add button, the addItem: message is sent to the target (the view controller). It responds as shown in Listing 7-5. It creates a navigation controller with a single view controller whose view is put onscreen modally—it animates upward to overlay the table view. The presentModalViewController:animated: method to do this.
Listing 7-5 Responding to a tap on the Add button
- (void)addItem:sender {
if (itemInputController == nil) {
itemInputController = [[ItemInputController alloc] init];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:itemInputController];
[[self navigationController] presentModalViewController:navigationController animated:YES];
[navigationController release];
}
The modal, or overlay, view consists of a single custom text field. The user enters text for the new table-view item and then taps a Save button. This button sends a save: action message to its target: the view controller for the modal view. As shown in Listing 7-6, the view controller extracts the string value from the text field and updates the application’s data-model array with it.
Listing 7-6 Adding the new item to the data-model array
- (void)save:sender {
UITextField *textField = [(EditableTableViewTextField *)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]] textField];
SimpleEditableListAppDelegate *controller = (SimpleEditableListAppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *newItem = textField.text;
if (newItem != nil) {
[controller insertObject:newItem inListAtIndex:[controller countOfList]];
}
[self dismissModalViewControllerAnimated:YES];
}
After the modal view is dismissed the table view is reloaded, and it now reflects the added item.