Develop a line of code series for iOS: input box for one line, and input box for ios

Source: Internet
Author: User

Develop a line of code series for iOS: input box for one line, and input box for ios

I recently summarized the common functions in the development process and found that sometimes I am doing repetitive work. Therefore, we decided to extract common functions for future use.

My idea is to use the least code to solve the problem. So I wrote some frequently-used tool classes and called them a line of code series... It seems quite frustrating ..

The general content is as follows:

1. Set the input box in one row

2. Get network requests in one row

3. Refresh up and down a row (whether to pull up or pull down or both)

4. Get the database in one row (write is still in progress and the function has been basically implemented)

5. Save images in one row

6. Locate in one row

7. Change network conditions in one row

8. set X in one row (small set of functions)



Input box in one line

The input box is often seen, especially when a lot of information needs to be filled in during registration, there will be two problems: the input box is blocked by the keyboard, how the keyboard disappears.

At that time, we considered the following situation: All input boxes are not of the same level, that is, multiple views are nested, and there are N input boxes. The input boxes may be UITextField, UITextView, and UISearchBar. So I wrote it according to this situation. As for the bugs in the middle, you can propose changes.

Because my personal limitations are too great, I still hope you can Fork and modify them so that other people can use the tools you write and do not engage in Technical Monopoly.

Principle: traverse the child view from the relative root view. If the child view is UITextField, UITextView, or UISearBar, set its inputAccessoryView to a global toolBar and write down its relative coordinates, and so on.

Use: If you use only one line of code, it will automatically determine the coordinates, and you can control the keyboard's disappearance mode: Click View disappears, click somewhere outside the keyboard to disappear, or click Finish to disappear.


- (void)viewDidLoad {    [super viewDidLoad];        [inputHelper setupInputHelperForView:self.view withDismissType:InputHelperDismissTypeTapGusture];    }



#import <Foundation/Foundation.h>#import <UIKit/UIKit.h>typedef NS_ENUM(NSInteger, InputHelperDismissType) {        InputHelperDismissTypeNone = 0,    InputHelperDismissTypeCleanMaskView,    InputHelperDismissTypeTapGusture};@interface InputHelper : NSObject+ (InputHelper *)sharedInputHelper;- (void)dismissInputHelper;- (void)setupInputHelperForView:(UIView *)view withDismissType:(InputHelperDismissType)dismissType;@end#define inputHelper [InputHelper sharedInputHelper]



Supported types:

Supports UITextField, UITextView, and UISearBar. This is common ..


Source code:

Click here or click me



The code below css makes the string and input box in the same row

For the <div id = "zifu"> and <input id = "inputshuru"> DIV, then let them float left to implement a string and input box in one line, as shown in the following code.
<Style type = "text/css">
# Zifu {width: 100px; float: left ;}
# Shurukuang {width: 200px; float: left ;}
</Style>
Of course, if you want to be beautiful, you still need to make some css modifications.

Html code. Click + on the left to add an input box in the next line. Click-on the right to delete the input box in the current line.

This is the effect. You can change it yourself!

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> test </title>
<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<Script type = "text/javascript" src = "jquery-1.6.min.js"> </script>
<Script type = "text/javascript">
Var I = 1;
Function addImage (){
$ ("# Div _" + I ). parent (). append ("<div id = 'div _" + (I + 1) + "'> </div> ");
I = I + 1;
Var div = $ ("# div _" + I );
Div. append ("<input type = 'button 'value = 'add 'id = 'addbtn _" + I + "'onclick = 'addimage () '> </input> ");
Div. append ("<input type = 'text' value = '" + I + "'> </input> ");
Div. append ("<input type = 'button 'value = 'delete' name = '" + I + "'id = 'addbtn _" + I + "'onclick = 'removeima. ..... remaining full text>


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.