zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    习题4.7利用vector实现数据复制
    习题4.18
    4.8编写一小段程序实现两vector是否相等的比较
    关于野指针
    学习c++的50条忠告
    c++头文件
    习题4.14
    容器和迭代器
    Android上C++对象的自动回收机制分析
    Windows下载Android源码
  • 原文地址:https://www.cnblogs.com/hubj/p/2541749.html
Copyright © 2011-2022 走看看