Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 将图纸放置在NSTableView中的某一行_Objective C_Macos_Cocoa - Fatal编程技术网

Objective c 将图纸放置在NSTableView中的某一行

Objective c 将图纸放置在NSTableView中的某一行,objective-c,macos,cocoa,Objective C,Macos,Cocoa,我正在尝试将图纸放置在NSTableView中某一行的正下方。我有行号,并且已经成功地将工作表定位在正确的列,但没有定位到正确的行 显然,NSRect是从包含tableView的窗口底部绘制的,我不知道如何让它识别行。。。我知道如何将工作表定位在按钮或文本字段NSRect cellRect=[myButton frame]但不是一行 任何建议或指点都会非常有用,谢谢 - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *

我正在尝试将图纸放置在NSTableView中某一行的正下方。我有行号,并且已经成功地将工作表定位在正确的列,但没有定位到正确的行

显然,NSRect是从包含
tableView
的窗口底部绘制的,我不知道如何让它识别行。。。我知道如何将工作表定位在按钮或文本字段
NSRect cellRect=[myButton frame]但不是一行

任何建议或指点都会非常有用,谢谢

- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect {
    //the row number is stored as a user default - convoluted but it is what it is
    int rowNumber = [[[NSUserDefaults standardUserDefaults] stringForKey:@"p"] intValue];
    NSRect cellFrame = [tableView frameOfCellAtColumn:2 row:rowNumber];
    cellFrame.size.height = 0;
    return cellFrame;
}

您需要将框架转换为windows坐标系谢谢,这让我走上了正确的轨道。我使用了以下方法来正确定位板材。请注意我的窗口特有的140偏移量<代码>NSInteger y=rectofCellinsPerview.origin.y;NSInteger屏幕高度=[[NSScreen screens]objectAtIndex:0]帧].size.height;NSSize MyNSWindowsSize=[tableView框架].大小;NSInteger yFromBottom=myNSWindowSize.height-y-140;NSIndexSet*indexSet=[NSIndexSet indexSetWithIndex:rowNumber];NSRect cellFrame=NSMakeRect(218,yFromBottom,100,30);cellFrame.size.height=0;返回单元框