• three20 解决tttaleviewcontroller 切换输入法的bug


      three20 比较方便,只要将autoresizesForKeyboard = YES就可以自动调整键盘位置,但是有一个bug,如果切换输入法将会导致view 消失,后来查了一下,找到了如下解决方法,可以直接将TTTableViewController.m 中代码替换成如下:当然我建议还是继承一下TTTableViewController,然后在子类中处理。

    ///////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    #pragma mark -
    #pragma mark TTViewController
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    - (void)keyboardDidAppear:(BOOL)animated withBounds:(CGRect)bounds {
        [super keyboardDidAppear:animated withBounds:bounds];
        CGRect screenRectInTableSuperView = [self.tableView.superview convertRect:[UIScreen mainScreen].bounds 
                                                                         fromView:[UIApplication sharedApplication].keyWindow];
        CGFloat bottomOffset = CGRectGetMaxY(screenRectInTableSuperView) - CGRectGetMaxY(self.tableView.frame);
        self.tableView.frame = TTRectContract(self.tableView.frame, 0, bounds.size.height - bottomOffset);
        [self.tableView scrollFirstResponderIntoView];
    }
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    - (void)keyboardWillDisappear:(BOOL)animated withBounds:(CGRect)bounds {
        [super keyboardWillDisappear:animated withBounds:bounds];
        
        if (_tableView) {
            CGRect previousFrame = self.tableView.frame;
            self.tableView.height = self.view.height;
            
            if (self.tableView.height > self.view.bounds.size.height) {
                self.tableView.frame = previousFrame;
            }
        }
    }

    原文:https://github.com/jeanregisser/three20/commit/026c9a65f1d91625e42cb7ca60d5eb97cd543a0a

    修复后的tttableviewcontroller.m

    https://github.com/jeanregisser/three20/blob/026c9a65f1d91625e42cb7ca60d5eb97cd543a0a/src/Three20UI/Sources/TTTableViewController.m

  • 相关阅读:
    Linux文件系统之INode
    手写Netty之多路复用Select小案例
    多路复用器Select、Poll、Epoll区别梳理
    NAT模式、路由模式、桥接模式的区别
    Netty编解码器(理论部分)
    Netty之Unpooled_Bytebuf
    为什么 TCP 协议有粘包问题
    IDEA_2019.1版本中Protobuf的使用
    Netty服务端Server代码说明
    Netty之ChannelHandler
  • 原文地址:https://www.cnblogs.com/hubj/p/2541749.html
Copyright © 2020-2023  润新知