UITextView* content = (UITextView*) [cell viewWithTag:104];

[content addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];

#pragma mark - KVO

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

{

    UITextView *tv = object;

    // Center vertical alignment

    CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height * [tv zoomScale])/2.0;

    topCorrect = ( topCorrect < 0.0 ? 0.0 : topCorrect );

    tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect};

    

} 

相关文章:

猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2021-04-15
相关资源
相似解决方案