题
我正在研究我的申请的GUI。我有一个嵌入到NSSCrollView的主视图。当用户单击按钮时,它的内容会刷新。然后,它确定显示内容所需的高度。该视图的显示不好,有很多故障,显示了两次的项目...我知道问题是当我用[自setBounds:...]设置视图大小时。您知道如何更改视图尺寸吗?这是代码:
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];
}
提前致谢!
解决方案
我再次找到了解决方案。我正在更改绘制方法中的NSView界限(尽管在执行任何图纸之前)。我在其他地方放了一件代码,现在它非常有效。
不隶属于 StackOverflow