zoukankan      html  css  js  c++  java
  • iOS解决表格中TextField,TextView编辑时,输入框被键盘遮挡的问题

    方法1:在原来的 UIViewController 内部再添加一层 UITableViewController

    代码如下 :

    //
    //  ViewController.m
    //  键盘遮挡问题
    //
    //  Created by 思 彭 on 17/2/4.
    //  Copyright © 2017年 思 彭. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "MyCell.h"
    
    static NSString *const identify = @"cell";
    
    @interface ViewController () <UITableViewDelegate, UITableViewDataSource>
    
    @property (nonatomic, strong) UITableView *tableView;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        
        [super viewDidLoad];
        self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        [self.view addSubview:self.tableView];
        
        [self.tableView registerClass:[MyCell class] forCellReuseIdentifier:identify];
        
        UITableViewController *tableViewVc = [[UITableViewController alloc]initWithStyle:UITableViewStylePlain];
        tableViewVc.tableView = self.tableView;
        [self addChildViewController:tableViewVc];
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        
        return 20;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        MyCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
        return cell;
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    @end

    方法2:监听键盘通知,在键盘出现或消失的时候修改tableView contentInset scrollIndicatorInsets

     

  • 相关阅读:
    keepalived的一些。。
    virtualbox复制了以后网卡启动不了。
    mysql安装之后需要调的参数
    mysql5.6 thread pool
    $releasever 不正确解析
    linux 被入侵后扫尾工作
    简单启动脚本编写
    tcmalloc安装
    rsyslog及loganalyzer
    nsswitch & pam
  • 原文地址:https://www.cnblogs.com/pengsi/p/6366376.html
Copyright © 2011-2022 走看看