IPhone DevelopmentApplication in progressNSTableViewRelevant operations are described in this article, mainly to learnNSTableViewHow to UseNSTableViewDrag/drop replacement and insert are also supported.
When yourNSTableViewAs a drag-and-drop target, you may wish to support both drag-and-drop replacement of the current project, or drag and drop to insert a new project in the current position. You need to use NSTableView's-setDropRow: dropOperation: method. This article describes how to implement the drag-and-drop function of NSTableView through code.
The Code is as follows:
- - (NSDragOperation) tableView: (NSTableView *) view
- validateDrop: (id ) info
- proposedRow: (int) row
- proposedDropOperation: (NSTableViewDropOperation) op
- {
- [view setDropRow: row
- dropOperation: op];
- NSDragOperation dragOp = NSDragOperationCopy;
- return (dragOp);
- }
In addition, perform the following operations in the acceptDrop method:
- -(BOOL) tableView: (NSTableView *) view
- AcceptDrop: (id) info
- Row: (int) row
- DropOperation: (NSTableViewDropOperation) op
- {
- If (op = NSTableViewDropOn ){
- // Replace
- } Else if (op = nstableviewdropabve ){
- // Insert
- } Else {
- NSLog (@ "unexpected operation (% d) in % s ",
- Op, _ FUNCTION __);
- }
- Return (YES );
- }
Get a notification when the NSTableView option is changed
The Code is as follows:
- - (void) tableViewSelectionDidChange: (NSNotification *) notification
- {
- int row;
- row = [tableView selectedRow];
-
- if (row == -1) {
- //do stuff for the no-rows-selected case
- }
-
- else {
- // do stuff for the selected row
- }
- }
This code should be placed in the delegate of NSTableView. If no delegate exists, you can set it to delegate.
Summary:IPhone DevelopmentApplication in progressNSTableViewThe related operations have been introduced. I hope this article will help you!