TextView滚动至最后一行 跳动的bug解决
在使用UITextView的时候遇到一个bug,自动换行的时候会光标会不停的跳动,并且文字无法显示完全,最后找到解决方法:
// ios7 bug fix
// check if the device is running iOS 7.0 or later
NSString *reqSysVer = @"7.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
if (osVersionSupported) {
NSTextStorage* textStorage = [[NSTextStorage alloc] init];
NSLayoutManager* layoutManager = [NSLayoutManager new];
[textStorage addLayoutManager:layoutManager];
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:self.view.bounds.size];
[layoutManager addTextContainer:textContainer];
yourTextView = [[UITextView alloc] initWithFrame:someFrameForYourTextView
textContainer:textContainer];
// if using ARC, remove these 3 lines
[textContainer release];
[layoutManager release];
[textStorage release];
}
else
yourTextView = [[UITextView alloc] initWithFrame:someFrameForYourTextView];