Objective c 编辑文本视图时如何禁用滚动? 我有一个UISCLVIEW视图,中间有一个UITExtVIEW,底部有一个按钮。 当我按下按钮时,我想编辑UItextView,然后滚动到顶部。问题是,当我按下按钮时,UITextView在代码中被编辑,然后它会自动滚动到此UITextView的行,并忽略我滚动到顶部的代码行 - (IBAction)SubmitForm:(id)sender { if ([Titre.text length] == 0 || [TypeIntervention.text length] == 0 || [Client.text length] == 0) { ErrorMsg.text = @"test"; [self.Scroll setContentOffset:CGPointMake(self.Scroll.contentOffset.x, 0)animated:YES]; } else { DoneMsg.text = @"test"; } }
实现UITextView委托并使用UIScrollView的scrollEnabled属性Objective c 编辑文本视图时如何禁用滚动? 我有一个UISCLVIEW视图,中间有一个UITExtVIEW,底部有一个按钮。 当我按下按钮时,我想编辑UItextView,然后滚动到顶部。问题是,当我按下按钮时,UITextView在代码中被编辑,然后它会自动滚动到此UITextView的行,并忽略我滚动到顶部的代码行 - (IBAction)SubmitForm:(id)sender { if ([Titre.text length] == 0 || [TypeIntervention.text length] == 0 || [Client.text length] == 0) { ErrorMsg.text = @"test"; [self.Scroll setContentOffset:CGPointMake(self.Scroll.contentOffset.x, 0)animated:YES]; } else { DoneMsg.text = @"test"; } },objective-c,ios,xcode,uiscrollview,uitextview,Objective C,Ios,Xcode,Uiscrollview,Uitextview,实现UITextView委托并使用UIScrollView的scrollEnabled属性 - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{ self.Scroll.scrollEnabled = NO; return YES; } - (void)textViewDidBeginEditing:(UITextView *)textView { self.Scroll.scrollEnabled =
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
self.Scroll.scrollEnabled = NO;
return YES;
}
- (void)textViewDidBeginEditing:(UITextView *)textView {
self.Scroll.scrollEnabled = NO;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
self.Scroll.scrollEnabled = YES;
return YES;
}
- (void)textViewDidEndEditing:(UITextView *)textView{
self.Scroll.scrollEnabled = YES;;
}
我确实将UITextView委托给了我的ViewController.m,然后在最后添加了这段代码,但当我按下按钮时,UITextView会发生变化,UIScrollView会滚动到UITextView。我在这里找到了答案