1
私は自分のアプリケーションのGUIに取り組んでいます。 NSScrollViewにメインビューが埋め込まれています。ユーザーがボタンをクリックすると、コンテンツが更新されます。次に、コンテンツを表示するために必要な高さを決定します。表示がうまく表示されず、項目が2回表示されていて、多くの不具合があります。問題は、[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];
}
ありがとうございます!