zoukankan      html  css  js  c++  java
  • (转)A drop-in universal solution for moving text fields out of the way of the keyboard

    There are a hundred and one proposed solutions out there for how to move UITextField andUITextView out of the way of the keyboard during editing — usually, it comes down to observing UIKeyboardWillShowNotification and UIKeyboardWillHideNotification, or implementing UITextFieldDelegate delegate methods, and adjusting the frame of the superview, or using UITableView‘sscrollToRowAtIndexPath:atScrollPosition:animated:, but all the proposed solutions I’ve found tend to be quite DIY, and have to be implemented for each view controller that needs it.

    I thought I’d put together a relatively universal, drop-in solution: UIScrollView andUITableView subclasses that handle everything.

    When the keyboard is about to appear, the subclass will find the subview that’s about to be edited, and adjust its frame and content offset to make sure that view is visible, with an animation to match the keyboard pop-up. When the keyboard disappears, it restores its prior size.

    It should work with basically any setup, either a UITableView-based interface, or one consisting of views placed manually.

    201104121152.jpgFor non-UITableViewControllers, use it as-is by dropping theTPKeyboardAvoidingScrollView source files into your project, popping aUIScrollView into your view controller’s xib, setting the class toTPKeyboardAvoidingScrollView, and putting all your controls within that scroll view.

    To use it with UITableViewController, pop theTPKeyboardAvoidingTableView source files in, and just make your UITableView aTPKeyboardAvoidingTableView in the xib — everything should be taken care of.

    You can grab the source files, which includes a sample project, over on the GitHub project page

     
  • 相关阅读:
    RAC RMAN 备份 RMAN03009 ORA19504 ORA27040 RMAN06012 channel c3 not allocated 错误分析
    Oracle 发送邮件 存储过程 代码
    RAC 之 RMAN 备份
    Oracle 一次小优化
    RAC 实例不能启动
    Oracle Hint
    RAC 之 RMAN 备份
    远程客户端 访问 ASM 实例
    RAC RMAN 备份 RMAN03009 ORA19504 ORA27040 RMAN06012 channel c3 not allocated 错误分析
    RAC the cluster database(DB_NAME) already exits
  • 原文地址:https://www.cnblogs.com/greywolf/p/3252156.html
Copyright © 2011-2022 走看看