NSSplitView 안에 포함 된 상당히 간단한 사용자 정의 뷰 클래스가 있습니다. 그 뷰 클래스는 NSMatrix와 몇 개의 더미 셀을 추가하여 그 자체를 채 웁니다. 정말 이상한 점은 슈퍼 뷰를 채울만한 크기가 있음에도 불구하고 사실 슈퍼 뷰보다 훨씬 크고 넓습니다. 나는 프레임과 범위를 기록하려고했는데, 그 결과도 아래에있다.하지만 나는 혼란 스럽다. 내가 기대했던대로이 작품의 크기가 슈퍼 뷰가 아닌 이유는 무엇일까요?범위 바깥 쪽 NSMatrix 드로잉
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NSImageCell *prototypeCell = [[NSImageCell alloc] init];
[prototypeCell setBordered:YES];
_matrix = [[NSMatrix alloc] initWithFrame:self.bounds
mode:NSHighlightModeMatrix
prototype:prototypeCell
numberOfRows:1
numberOfColumns:1];
[_matrix setCellSize:NSMakeSize(50, 50)];
[_matrix setBackgroundColor:[NSColor redColor]];
_matrix.drawsBackground = YES;
[_matrix addRow];
NSCell *cell = [_matrix cellAtRow:0 column:0];
[cell setImage:[NSImage imageNamed:@"block.png"]];
cell = [_matrix cellAtRow:1 column:0];
[cell setImage:[NSImage imageNamed:@"block.png"]];
[self addSubview:_matrix];
NSLog(@"%@", NSStringFromRect(self.bounds));
NSLog(@"%@", NSStringFromRect(self.frame));
NSLog(@"%@", NSStringFromRect(_matrix.bounds));
NSLog(@"%@", NSStringFromRect(_matrix.frame));
}
return self;
}
Output:
2014-02-15 15:16:23.458 Temp[5970:303] {{0, 0}, {45, 331}}
2014-02-15 15:16:23.459 Temp[5970:303] {{500, 0}, {45, 331}}
2014-02-15 15:16:23.459 Temp[5970:303] {{0, 0}, {45, 331}}
2014-02-15 15:16:23.459 Temp[5970:303] {{0, 0}, {45, 331}}
당신은 절대적으로 맞습니다. 저는 다른 문제를 쫓아 내려고 노력했지만, 다시 삽입하는 것을 잊었습니다. 고마워요! – XeroxDucati