UIPageViewController/TextKit Reflowing Text on paging

人走茶凉 提交于 2019-12-03 17:10:44
ytll21

I faced the same issue. My solution is to put the scrollEnabled after addSubview will force the textContainer re-calculate the size. See below code:

vc.view.addSubview(textView)
textView.scrollEnabled = false;

Update. Finally, I think I found the right answer... We need to reset the container size in the didChangeGeometryFromSize callback. Please correct me if it is not true :)

func layoutManager(layoutManager: NSLayoutManager, 
                   textContainer: NSTextContainer, 
                   didChangeGeometryFromSize oldSize: CGSize) {

    textContainer.size = self.textFrame().size;
    println(textContainer.size.width)
    println(textContainer.size.height)
}
Rodion

Try to set automaticallyAdjustsScrollViewInsets of your view controller to NO.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!