zoukankan      html  css  js  c++  java
  • iOS7光标问题

    iOS7光标问题

    有网友遇到textView在ios7上出现编辑进入最后一行时光标消失,看不到最后一行,变成盲打,stackOverFlow网站上有大神指出,是ios7本身bug,加上下面一段代码即可(网友调试得出,在此mark一下,有问题,欢迎大神们指出)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    -(void)textViewDidChange:(UITextView *)textView {
        CGRect line = [textView caretRectForPosition:
                       textView.selectedTextRange.start];
        CGFloat overflow = line.origin.y + line.size.height
        - ( textView.contentOffset.y + textView.bounds.size.height
           - textView.contentInset.bottom - textView.contentInset.top );
        if ( overflow > 0 ) {
            // We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
            // Scroll caret to visible area
            CGPoint offset = textView.contentOffset;
            offset.y += overflow + 7; // leave 7 pixels margin
            // Cannot animate with setContentOffset:animated: or caret will not appear
            [UIView animateWithDuration:.2 animations:^{
                [textView setContentOffset:offset];
            }];
        }
    }
  • 相关阅读:
    浅谈SQL Server 对于内存的管理
    【JSON解析】JSON解析
    SQLSERVER吞噬内存解决记录
    数据schemaAvro简介
    Windows命令查看文件MD5
    均分纸牌(贪心)
    an easy problem(贪心)
    导弹拦截问题(贪心)
    活动选择(贪心)
    整数区间(贪心)
  • 原文地址:https://www.cnblogs.com/sgdkg/p/4684156.html
Copyright © 2011-2022 走看看