Miss Miss 3rd day: Login Registration Screen Building

Source: Internet
Author: User
Tags configuration settings

One: Login Registration Interface Effect

Second: The construction of the interface

1: Landing interface is generally MODA mode: New controller, tick Xib, then the system will automatically associate the class, and automatically connect the view (if the controller created after the Xib, the class name is the same, the association class, the Fileower line view), And we don't have to set the frame of the controller view ourselves. or freeform, only need to change the size of the controller view, such as 4.7-inch, then the normal fit on other models. 2: The general background is more beautiful than the background picture. 3: Control the style of the status bar: 1:[uiapplication Sharedapplication].statusbarstyle; Set the global status of the navigation bar, also need to configure the plist, set the view controller base to No (not recommended) 2: From the beginning of iOS7 can be in the controller, set the value of the status bar. -(Uistatusbarstyle) Preferredstatusbarstyle

{return uistatusbarstylelightcontent;}

Set one, the other is not used, the first is not recommended, the default color is black. 2: Hide the status bar:-(BOOL) Prefersstatusbarhidden If pills is configured, use [UIApplication sharedapplication].statusbar Hidden

2: UI Analysis of Login interface: 1: Controller or view, think of layered packaging idea (refer to the package of Sina Weibo cell), divide the controller or view into modules, analyze which controls are composed of each module. The scattered controls are encapsulated within a unified module (specific to the method of view), and then see whether the internal view of each module of the package can continue to encapsulate, and then look at the encapsulated view, whether the other parts of the project can also be used, if possible, then think of inheritance, the public part of the parent class, Subclass to inherit the parent class, the different parts are implemented in the subclass, 1: The parent class can expose the method in. h, and then implement the method in. m, the subclass inherits the method of the parent class, and when the subclass calls the method of the parent class, it invokes the implementation of the parent class. (Sina Weibo parametric model of the extraction of the parent class inheritance) 2: If there are multiple subclasses inheriting the same parent class, in the parent class to perform different methods according to different subclasses, the parent class can provide an identity property method for subclass inheritance to override its Get method, At this point in the parent class can distinguish between different subclasses (best of the main interface inheritance structure) 3: If the parent class provides a method, the parent class also implements the method, after the subclass inherits the method, continue to override the method, 1: If the parent class behavior is not preserved, you can not call super. 2: Call code write above super, rewrite Setframe method, re-design parameters into Super Method 3: Write under Super, first preserve the behavior of the parent class, in the set subclass of the behavior 2: The landing interface, then encapsulated into three view, the upper one view, In the middle of a view, the bottom of a view, and for the bottom of the view, can also be encapsulated into two view, the upper one view, the bottom of a view, the bottom of the View button and can continue to package 3: When the copy of the Xib has been set in the constraint control, only copy the width of the height constraints, Other constraints are not copied. The middle is lable, and the sides are uimageview.

Supplement: 1: Sina Weibo cell Package MVVM thought: 1: The package background view0 added directly to the cell, and the micro-blog body view1 and the bottom toolbar view2, encapsulated to add to the view0, the bottom of the toolbar view2 encapsulated as a whole view2, Micro-bo text of the View1 hierarchy for the original micro-Bo VIEW3 and forward micro-Bo View4, the avatar nickname Time Crown, micro-bo content, pictures and other information are encapsulated in the original micro-Bo VIEW3, which micro-bo pictures and encapsulated a layer of VIEW5, specifically used to display pictures, Tweet text and pictures are added to VIEW4. Note: Whether or not the display is displayed, all the controls displayed as much as possible are added to the encapsulated view, and the control is displayed or hidden based on the field values of the data model, taking into account the cell's recycling (shown and hidden back), avoiding data confusion due to cell multiplexing. 2:MVVM thought: The Cellframe package as a data model, in the Cellframe data model of the internal status data model as the Cellframe data Model properties, based on the status Data model field values to set to a control frame, Benefits of Cellframe: You can set a frame for a control, and you can set property values for a control. Each package view corresponds to a cellframe model, and the data source inside the controller is the Cellframe data model for the storage. MVVM's thought hierarchy is clearer, simplifying the controller's code for ease of maintenance 3: How to set the cell's height: 1: Set in cell: Provides a class method in the cell to pass in the data model of each row row, calculates the total cell height according to the field value of the data model 2: Provide a height attribute in model, override the Get method in model, calculate the total cell's height according to the field value in model, in order to optimize, also can set the memory cache, when calculate the height of the cell, let it return directly, no longer perform the method of calculating height. (Recommended second type)

2:view Encapsulation Method: Both code and xib think of the idea of modular layered encapsulation.

The

1:instancetype method provides a class method for quickly returning an object, 1: Internally calling Alloc init, alloc init internal call [Alloc  initwithframe] method, [Super   initWithFrame] will call the Setframe method, you can override the Setframe method to set its own fixed frame, prohibit external changes, you can also override the Setframe set the cell's upper and lower left and right spacing, split line, etc., when the outside set frame, The Setframe method is called again, and when the Setframe method call is complete, the Layoutsubview method is called to set frame 2: You can set some specific properties of your own package view in the [Alloc  initwithframe] Method , or one-time code 2: Lazy Loading of child controls: (Lazy Load effect: 1: Do not consider the code creation Order 2: Guaranteed to initialize only once  3: lazy loading available weak and strong can) set the child control's properties in lazy loading methods and add child controls to the parent control.

2: Override the Layoutsubview method to set the child control's frame: Setting the child control's frame in this method is more accurate and rigorous, don't forget to call super, and this method works with Setneedslayout and Layoutifneed: The former calls the Layoutsubview method asynchronously, and the latter layoutifneed calls the Layoutsubview method immediately to update the constraint. 1: How to get the control: 1: Attribute, member variable, enumeration tag value (1: Direct fetch, 2: or traverse the parent control's child control array, by tag value, the tag value is generally not set to 0, unsafe, because all controls default tag value is 0 3: Generally when setting the tag value by Self.subviews,count can also set the tag value), or inherit the parent class directly from the parent class properties get   2: The created control is placed in a large array of property definitions, if the control contains a non-homogeneous 22 in a large array, Remove child controls from an array by a for loop in Layoutsubview 3: Traverse the parent control's child controls array: 1:self.subviews (UIView and scroll hide two scroll bars is the purest view, except that you add no child controls. So you can traverse the parent control's child control array directly, you need the index to take the int i traversal, do not need to take the for-in fast traversal, and the external definition index, internal index++, to record the index value, you can also use Enumer to iterate the index value and traverse the object. In the traversal, the first to do conditional filtering (1:continue 2:return filter, do not execute return code, 3:break, jump out of the loop, no longer loop) found after setting the value, and stop traversing 2: If you traverse the parent control's Self.subviews child control array, sometimes the system parent control does not directly provide the property to use, at this point, you can print the child control array or through Viewui to debug to see what the child control is, so that you can get the child control from the string into a class, Nsclassfromstring () (Sina set middle plus button) 3: Use Runtime to get the properties of the system control private to set

3: Design the Model interface and business logic interface for the package view: Design the model interface and override the model's set method to assign values to the child controls that encapsulate the view. The interface design of business logic: 1: The outside of the business logic is encapsulated in the internal class, the class provides the interface for external access to ensure the most concise and convenient outside the 2: the interface design: The general use of property interface overrides by overriding the method interface, whether to provide the bool attribute interface, different types, An enumeration type interface is provided, and the outside world wants to access what methods are inside the class, and the variables provide an external property interface.

4: The business logic of the Monitoring processing: 1: See if the sub-class there is no system proxy method, notification method, or inherit Uicontrol can be addtarget can implement monitoring, if the subclass can not also see the parent class has the above method, when viewing the system's API, You can view the instructions for using this method in its English comments, or you can hold down the option key to view the instructions for use 2: Overwrite the listener: Problems encountered in development first consider rewriting, rewrite is very useful, inherit the parent class, by overriding the parent class method can also intercept the behavior of the parent class, Overwrite or listen to the behavior of the parent class. But don't forget to call Super, otherwise the default behavior of the parent class will not respond. 3: When listening to the properties of their own changes, you can use KVO to implement monitoring, when the property changes can be implemented some methods

5: Listener callback: 1: The level is shallow, with the protocol proxy (1: Modeled TableView Proxy method to design the protocol Proxy 2: sometimes need to rewrite the Setdelegate method, that is, after the agent can do some settings) block, both can, when two classes need to callback each other , you can set the return value of the Protocol agent or block, you can achieve two classes each other callback 2: The depth of the hierarchy: You can use the notification callback, the value, where the notification can be executed in the current thread or sub-thread (only when the post notification in which thread, after registering the observer, the execution of the notification party The method is on which thread), in which the registered observer can also register the observer with block mode, and specify which thread the block task will be executed on (or a one-time notification can be implemented, the observer is canceled after the task is performed in the Block), and if the Observer is registered with block, To accept the return value of a block notification with the familiar definition ID type return value class, to unregister the observer in Dealloc. Notification names in general items are written in the class of the configuration constants

6: Consider the inheritance relationship: If the package of the view in the other parts of the project can also be used, then consider using inheritance, the same part of the parent class, let the subclass to inherit, different parts in the subclass implementation, the parent class can give the subclass to provide a way for subclasses to rewrite, to implement the parent class and subclasses of each other's association

7: Problem Analysis: When the system provided by the control does not meet our requirements, we can choose custom control, custom control to inherit the control of the system, 1: Override the Layoutsubview method, 1: Within the method directly get the control of the system to set 2: If you cannot get directly to the system's child controls, Traverse the system control's child control array inside the method and print or debug the View child control through Viewui, and then set it through nsclassfromstring 3: Use runtime to get the system control inside the private member variable to set (change the text box placeholder text color) 2: Through the inheritance relationship, the child class of the custom control overrides the parent class's method, super calls three kinds of cases. By overriding the methods of the parent class, you can listen to the behavior of the parent class, overwrite, modify 3: You can also write classification for the class of the system, provide the method in the classification

3: The code in the controller specification: 1: First analysis of the interface UI, analysis of the packaging structure of the interface, first to tidy up the logic, the logic straightened out, and then go to write code 2:1: in the controller to implement the + (void) load, Do some common configuration (for example, configure the configuration of the Mjextension dictionary to model), regardless of whether there is a subclass, the method executes only once, and can be called without importing the header file, that is, the class is loaded into memory will call the + (void) Initalize the method may be called multiple times, When the class is initially called, when there is a subclass, the + (void) Initalize method of the parent class is called, and the + (void) Initalize method of the subclass is called (the parent class overrides the + (void) Initalize method, the subclass inherits, No Override), In this method, you can initialize some configuration settings or just one-time settings (custom navigation controller set global navigation theme, or database table) override the controller's Init method, you can pass the parameters during controller creation initialization, or do some fixed disposable settings when initializing. For example, setting the TableView style can be called at initialization time, and the controller Init method is called when the controller initializes. -(void) Loadview method, override this method to change the controller's Self.view  viewdidload method, call After view is loaded, viewwillappear or viewwilldidappear These two methods will be called more than once, as long as the interface appears to be called, Pop,dissmiss will be called, generally in the Viewdidappear method to print the control's information, because the control is now fully displayed, Viewwilldisappear, Viewdiddisappear page is about to disappear or has disappeared when the call, Dealloc controller destroyed when the call, in this method can remove the notification or when the controller is destroyed by the other controller to pass some data information. 2: We generally take the encapsulation method in the Viewdidload method call 1: When a method in the controller contains a large number of duplicate code to consider the extraction method encapsulation, the same code is drawn to the inside of the method, different parts as parameters passed 2: If the code involves the processing of some business logic or the project can be used in various places, you should also consider the package: 1: Classification Package: 1: When this segment of business logic and the system has a relationship with a class, you want to write classification of the system class, and can write classification as far as possible to write classification, because the classification will be less 2: Classification of Interface Design: Object method or Class method, class method is more rude than object method, but when it is necessary to pass two parametersConsider using object methods, where self in the classification refers to the passed parameters, and if the variables are defined with attributes in the classification, only the set and get declarations are generated, and no implementation is generated and no underlined member variables are generated. If the outside world wants to access a variable at this point, it can be returned in the Get method with the global variable defined by static. 2: Management class Tool Encapsulation: Single or class method, if you want to get the same member variable in the class method, use static to define the global variable. This member variable can also be lazy-loading mode, only to initialize it once, if the outside world wants to access the member variable, the class can provide an interface get method interface for external calls (Get method interface can also be called with point syntax) 3: Consider the inheritance: the same part is pumped to the parent class, Different parts are implemented in sub-classes, the parent class can expose a method in. h for subclasses to override (the parent class can provide an identity property for subclasses to override, so that different subclasses are distinguished in the parent class), and the subclass overrides the parent class's method, which is equivalent to indirectly modifying the parent class's properties, and the parent class can also get the properties modified by the child class. 3: The controller or view in each line of code to write, should strive to make the most concise, to repeated deliberation, refining, until the code is the most concise can not be smoked until then. 1: Like a hidden or return bool value of the method of a code to solve or use the trinocular operation to simplify IfElse 2: The assignment of three, the top position nil, the middle assignment, the last assignment of 3: There are two return values, only one if, respectively, without if else 4: when traversing, The conditional filter (Continue,braek, or return conditional filtering) is first done to find the assignment and stop the traversal.  

Miss Miss 3rd day: Login Registration Screen Building

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.