English 中文(简体)
观点支持的NSTableView:插入Column Width/Margin Issues
原标题:View-backed NSTableView: Inserted Column Width/Margin Issues

I have a view-based NSTableView that usually has one column in it. However, at a button press, I want a new column to slide in from the left (very similar to what happens on an iPhone when you click the Edit button in Mail). For now, the view that I want to slide is in a very simple view that draws a solid background: its drawRect: just does

[[NSColor blueColor] set];    
[[NSBezierPath bezierPathWithRect:[self bounds]] fill];

在代表本人的NSTableView中,我有:

- (IBAction)buttonPressed:(id)sender
{
        NSTableColumn *newColumn = [[NSTableColumn alloc] initWithIdentifier:@"InPreviewColumn"];
        [newColumn setWidth:40];
        [newColumn setMinWidth:[newColumn width]];
        /* To make up for there not being an insertColumnAt: method, 
           hide the column, add it, and move it to the front before showing it. */
        [newColumn setHidden:YES];

        [availableFontsView beginUpdates];
        [availableFontsView addTableColumn:newColumn];
        [availableFontsView moveColumn:1 toColumn:0];
        [availableFontsView endUpdates];
        [newColumn setHidden:NO];
}

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
   /* ... code for main column ... */
   else if([[tableColumn identifier] isEqualToString:@"InPreviewColumn"])
   {
     USSolidBackgroundView *v = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:self];
     if(!v)
     {
        v = [[[USSolidBackgroundView alloc] initWithFrame:NSMakeRect(0, 0, [tableColumn width], 0)] autorelease];
        [v setIdentifier:[tableColumn identifier]];
        [v setAutoresizingMask:NSViewMinXMargin | NSViewWidthSizable | NSViewMaxXMargin];
     }

     return v;
     }
}

Yet, when I do this, I end up with this result (there s a big non-blue margin between the blue part of the new column and the start of the main column):

“entergraph

当增加一栏的斜线出现时,没有差值,因此我很相信问题与另一种观点无关(因为它只看所显示的观点时没有差值)。

我用伐木记录来核实,坚固的彩色观察束总有40个宽度(图形:)而且,至少当形成这种观点时,表列也有40个宽度。

So where does this margin come from? No matter how I size the column, it seem that only roughly half of it is blue. So, the bigger the column, the bigger the margin.

我如何使整个额外一栏成为蓝色?

最佳回答

问题在于我: 我认为,从字体上看,我的立场是建立在[自己的框架]之上的。 这是错误的。

[self bounds] is the way to go. Which I knew. Can t believe I made this mistake. Amateur hour.

如果你回避这一问题,就感到可以自由投票结束这一问题,或者说,在Stackover流程上应该做什么。

我道歉。

问题回答

暂无回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签