[英]UITextView Inside UIScrollView Scrolling Parent as Text is Entered
我有一個包含UITextView
的UIScrollView
。 當文本輸入到UITextView
, UIScrollView
將滾動以確保文本在內容框架中完全可見。 我不想要這個。
我已禁用UIScrollView
上的滾動,但這沒有任何效果。 誰知道如何制止這個? 可在此處找到示例項目: http : //cl.ly/1P1u3y302r3q1f1C063K 。
謝謝!
我有與UITextView
類似的問題。 似乎scrollEnabled
屬性不會取消自動滾動。 我通過重寫setContentOffset:
方法解決了這個問題 。
以下preventScrolling
標志可能會有所幫助:
@interface MyScrollView : UIScrollView
@property (nonatomic, assign) BOOL preventScrolling;
@end
@implementation MyScrollView
@synthesize preventScrolling;
-(void) setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
{
if(!self.preventScrolling) {
[super setContentOffset:contentOffset animated:animated];
}
}
@end
你設置了錯誤的contentSize:滾動視圖....
總是根據滾動視圖內的內容設置內容大小,如果內容高度和寬度大於滾動視圖的高度和寬度,則只增加內容大小,否則將其與滾動視圖的寬度和高度相同
[self.mainScrollView setContentSize:CGSizeMake(4096, 4096)];
而不是它把這個內容:
[self.mainScrollView setContentSize:CGSizeMake(mainScrollView.frame.size.width, mainScrollView.frame.size.height)];
這可能會對你有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.