Recently summed up the development process often used in the function, found that sometimes I am doing repetitive labor. So I decided to take out the frequently used functions and make them easy to use next time.
My idea is to solve this problem with the least amount of code. So write some frequently used tool class, the name is called a line of code series it ... It seems to be quite lame.
The general contents are:
1, a line to fix the input box
2, a line to solve the network request
3, a row to fix up and down the refresh (will be self-motivated to infer whether pull or pull or both coexist)
4, a row of database (recently still write, the function has been basically implemented)
5, a row to save the picture
6, a line to fix the positioning
7, a line to deal with network conditions change
8, a row of X (small collection of functions)
Line up the input box
Input box often see, especially when the register to fill a lot of information, this time there will be 2 questions: the input box is blocked by the keyboard, how the keyboard disappears.
At that time, considering a situation is: all the input box is not a sibling, that is, multiple views nested, and then there are n input boxes, the input box may be uitextfield,uitextview,uisearchbar. So in accordance with this situation wrote down, as to the middle of the bug, we can propose changes.
Because of the limitations of the individual is too large, or hope that everyone fork and change, so that other people can use the tools you write, do not engage in technical monopoly and so on.
Principle: Traversing a sub-view from a relative root view, assuming that the child view is Uitextfield,uitextview,uisearbar, set its Inputaccessoryview to Global toolbar, write down its relative coordinates at the same time, and so on.
Use: Using just one line of code, it will self-infer coordinates, at the same time you can control how the keyboard disappears: Click the view disappears, or click somewhere outside the keyboard disappears, or click Finish disappears.
-(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]
Type of support:
3 types of Uitextfield,uitextview,uisearbar are supported. The common will be able to.
Source:
Click here or point me
iOS Development line of code series: line up the input box