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

相关文章:

  • 2021-11-07
  • 2022-01-10
  • 2021-12-19
  • 2022-12-23
  • 2021-05-12
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2021-11-16
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案