UITextView scrollEnabled = YES not working after set scrollEnabled = NO in iOS8

后端 未结 8 901
失恋的感觉
失恋的感觉 2021-02-07 02:49

I create a demo for checking UITextView scrollEnabled. It only contains 1 UITextView and 2 button enable and disable scroll

  • I test on

8条回答
  •  一个人的身影
    2021-02-07 03:30

    After searching hours i am found one way

    -(IBAction)enableScrollButtonPressed:(id)sender{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.myTextView.scrollEnabled = YES;
        [self.myTextView setText:self.myTextView.text];
    
        self.myTextView.layoutManager.allowsNonContiguousLayout = false;
    
    });
    
    }
    
    -(IBAction)disableScrollButtonPressed:(id)sender{
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.myTextView.scrollEnabled = NO;
    });
    
    }
    

    condition for that is you need to scroll first then you it will work perfectly

    Means when disable scroll button is tapped textview should be scrolled at some position must not to at default position

提交回复
热议问题