1
내 응용 프로그램의 GUI에서 작업하고 있습니다. 기본보기 NSScrollView에 포함되어 있습니다. 사용자가 버튼을 클릭하면 해당 내용이 새로 고쳐집니다. 그런 다음 내용을 표시하는 데 필요한 높이를 결정합니다. 뷰가 잘 표시되지 않고, 두 번 표시되는 항목에 많은 결함이 있습니다 ... [self setBounds : ...]로 뷰 크기를 설정할 때 문제가 있음을 압니다. 보기 크기를 어떻게 변경할 수 있는지 알고 있습니까? 여기에 코드가 있습니다 :nsview 크기 설정
CGFloat allHeight= 0.0;
for(int i=0; i < [publications count]; i++) {
Publication* pub= [publications objectAtIndex:i];
CGFloat pubHeight= [self heightForTextStorage:[pub statusContent] withWidth:300];
if (pubHeight < 100.0)
pubHeight= 100.0;
allHeight += pubHeight;
}
if (allHeight > [[self superview] bounds].size.height) {
NSRect allBounds= self.frame;
allBounds.size.height= allHeight;
[self setFrame:allBounds];
}
else {
NSRect allBounds= [[self superview] bounds];
[self setFrame:allBounds];
}
미리 감사드립니다!