弹出键盘时按钮自动上移
2016-04-21 23:53
169 查看
话不多说,上图:
用到了TPKeyboardAvoiding框架,代码如下:
在viewController中:
#import "ViewController.h"
#import "TPKeyboardAvoidingScrollView.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
TPKeyboardAvoidingScrollView *scrollview = [[TPKeyboardAvoidingScrollView alloc]initWithFrame:self.view.frame];
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 500, 100, 100)];
textField.backgroundColor = [UIColor redColor];
[scrollview addSubview:textField];
[self.view addSubview:scrollview];
}
用到了TPKeyboardAvoiding框架,代码如下:
在viewController中:
#import "ViewController.h"
#import "TPKeyboardAvoidingScrollView.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
TPKeyboardAvoidingScrollView *scrollview = [[TPKeyboardAvoidingScrollView alloc]initWithFrame:self.view.frame];
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 500, 100, 100)];
textField.backgroundColor = [UIColor redColor];
[scrollview addSubview:textField];
[self.view addSubview:scrollview];
}
相关文章推荐
- Navicat for MySQL 工具注册码
- 前端笔记 CSS 5
- android中Activity中的WindowManager与Window
- Excel转PDF的相关问题处理
- 二维情形下的最接近点对问题
- 向量时钟Vector Clock in Riak
- 一个新奇的东西,调试布局利器
- Web系统架构分层
- 第9周学习进度表
- wewe
- Modern PHP读书笔记一
- Python爬虫笔记----爬虫技术入门(1)
- excel的导入导出
- 考研回忆录之时间效率
- iOS开发真机调试与App上架
- java Thread sleep yield join wait notify notifyAll
- 八九周学习总结
- bfs题目集锦
- Leetcode #50. Pow(x, n) 幂实现 解题报告
- SQLAutoCode - error when attempting to generate schema