[IOS] UITableViewController

Source: Internet
Author: User

[IOS] UITableViewController

UITableViewController can adapt to the keyboard itself (the focus of the control in the cell will be moved to the top of the keyboard

I thought about the following solution when I was doing keyboard retrieval:

1. Add a click event in tableview

Result: The didselect conflict between the Click Event and tableview, resulting in didselect failure.

2. scrollview

Result: The target can be achieved, but when you click textfield, the keyboard will appear and then be taken back directly. The reason is that the scrollview proxy is called.

Finally, the following solution is adopted:

 

 

_ SureBtn = [UIButton buttonWithType: UIButtonTypeCustom]; _ sureBtn. frame = CGRectMake (self. view. size. width-60, 5, 50, 28); _ sureBtn. backgroundColor = [UIColor colorWithRed: 0.150 green: 0.662 blue: 0.915 alpha: 1.000]; _ sureBtn. titleLabel. font = [UIFont systemFontOfSize: 15]; _ sureBtn. layer. cornerRadius = 5.0; [_ sureBtn setTitle: @ forState: UIControlStateNormal]; [_ sureBtn addTarget: self action: @ selector (changeRemarks) forControlEvents: UIControlEventTouchUpInside]; _ view = [[UIView alloc] initWithFrame: CGRectMake (0, 0, self. view. frame. size. width, 40)]; _ view. backgroundColor = [UIColor whiteColor]; UIView * line = [[UIView alloc] initWithFrame: CGRectMake (0, 0, self. view. frame. size. width, 0.5)]; line. backgroundColor = [UIColor blackColor]; [_ view addSubview: line]; [_ view addSubview: _ sureBtn];


 

In use, process Textfield as follows:

 

 

 _begoodatField.inputAccessoryView = _view;

For the cell text box in tableview

 

You need to define a temporary textfield.

When using

 

_ XuexiaoField = cellMenu. celltext; _ xuexiaoField. inputAccessoryView = _ view; // cellMenu indicates the name of the custom cell.
Attach the confirmation button
- (void)changeRemarks{    [_nicktextField resignFirstResponder];    [_xuexiaoField resignFirstResponder];    [_begoodatField resignFirstResponder ];    [_bumenField resignFirstResponder ];}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.