开发者

Making a Method be triggered when a row is selected in a Table View

How would I trigger a Method when a row in a Tab开发者_开发百科le View is selected?


You need to use NSTableViewDelegate to control what happens when you use a NSTableView. If your relevant view holding the table is named MyViewController, your interface (.h) file should start like this:

@interface MyViewController : NSObject <NSTableViewDelegate> {

And then in your implementation (.m) file, have this:

- (id)init {
     [super init];
     myTableView.delegate = self;
     return self;
}

- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex {
     NSLog(@"%i tapped!", rowIndex);
     return YES;
}


Here is a link to the NSTableViewDelegate docs.


Am I missing something? Just call it in the following delegate method: didSelectRowAtIndexPath

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜