滚动视图存在问题。我已经实现了两个字体调整大小按钮来增加或减少滚动视图中嵌入的文本视图的文本字体大小。但在减小字体大小后,我计算滚动视图内容并重新调整它以适应新的文本视图高度。但每次我修改文本字体时,它都会向下滚动每一步。
以下是代码:
- (IBAction)decreaseText:(id)sender {
int MyTextSizeMin = 8;
int MyTextSizeMax = 20;
// disable buttons when they're out of the range.
BOOL smallerEnabled = textFontSize > MyTextSizeMin;
BOOL biggerEnabled = textFontSize < MyTextSizeMax;
[self.decreaseText setEnabled:smallerEnabled];
[self.increaseText setEnabled:biggerEnabled];
height =0;
CGFloat secondLabelsize = texto.font.pointSize;
[texto setFont:[UIFont systemFontOfSize:(secondLabelsize-1)]];
CGRect frame = texto.frame;
frame.size.height = texto.contentSize.height;
self.texto.frame = frame;
height +=texto.contentSize.height;
height += self.imagen.image.size.height;
height += self.fecha.frame.size.height;
height += self.titulo.frame.size.height;
height += 200;
self.scrollView.contentSize=CGSizeMake(300.0,height);
[self.scrollView setNeedsDisplay];
}
如何禁用此不受欢迎的滚动?
非常感谢!
答案 0 :(得分:1)
尝试它可能对你有帮助。
[scrollView scrollRectToVisible:CGRect animated:BOOL];