Struggle. PNG

I have been in a harmonious society for nearly three years. It is not happy to celebrate the New Year. This year, my first choice for friends/children to find “psychological balance” is still brother. Holding a bunch of cool water up onto your face, looked up and look in the mirror looking at still chai “skinny” yourself, look at the time to thoroughly “forehead”, into the eyes of the cloudy but still firm, brother want to say to yourself: “goose, you can, although there is no good cooperation before, you will succeed one day, while it is very far away! Darling, good, silly B can write a thread……”

preface

In any software development, our principle is to strive for “high cohesion and low coupling”. The so-called “low coupling” refers to the coupling degree or correlation degree between modules in the software structure. The complexity of interface call and implementation between modules, and the number of interactive data determines the level of software coupling degree. The so-called “high cohesion” is from the level of internal functions of the module. The tightness of the code elements of a specific function inside the module determines the level of code cohesion.

Online there is no lack of so-called “ten minutes to build a strong APP framework”, “fast to build a strong APP framework” and other posts, and not to speak of good or bad, in short, practice is the only standard to test the truth, today I simply report under my project, the framework of the building process and matters for attention.

Frame structures,

Framing is a lot of work, because you have to think about all sorts of things when you’re framing, like: How do you design to make the flow clearer? How to design easier division of labor collaboration? How to design code modules that are easier to locate quickly? How to ensure the scalability of the system? And so on is that we have to grasp in advance. Take a look at the rough renderings as follows:





PNG image effect





Final effect.gif

First, frame structure

The structure of APP is generally divided into three lines:

  • A main frame flow;
  • One is the user login framework process;
  • One other page such as advertising page, welcome page, etc

Relatively speaking, the main framework process is relatively complex. The top container is UITabBarController, and the sub-container is UINavigationController. The top container contains 3-5 navigation controllers, and the rootViewController of the navigation controller is the home page of each module. The login framework process and other processes are generally linear, and some of them involve the switch of the root view, which is relatively simple. If drawn as a tree structure diagram, it is roughly as follows:





APP structure diagram. PNG

2. StoryBoard separation

To make it easy to configure tripartite libraries, I use the CocoaPods project (based on CocoaPods 1.1.1) to add tripartite libraries to my Podfile:

platform: ios, '8.0'target' EVNEstorePlatform 'do

pod 'MBProgressHUD'.'~ > 1.0.0'
pod 'FMDB'
pod 'SDWebImage'.'~ > 3.8'
pod 'IQKeyboardManager'.'~ > 3.3.7'
pod 'MJRefresh'
pod 'MJExtension'
pod 'MWPhotoBrowser'
pod 'AFNetworking'.'~ > 3.0'

endCopy the code

If you encounter problems, refer to CocoaPods working principle and problems encountered during use to solve them or ask them.

In actual project development, there is no better framework, the structure is more or less the same, suitable for their own team is the most important. In terms of frame building and interface layout, some teams like storyboards because what you see is what you get is easy to introduce to laymen. All the interfaces of a module are spread across the screen, which makes it cool. Some teams like pure code, and it’s indescribably satisfying to see themselves writing strings of characters to render “mysterious” animations. Of course, our team is in the middle of the road, framing + individual simple interfaces we use StoryBoard, and the rest use pure code, which is also the result of being forced to step on the hole.





StoryBoard.png

There’s no denying that storyboards have a lot of advantages, but for collaborative development, there can be some unspeakable pain, such as: conflicts when modifying StoryBoard files at the same time; Even subtle shifts require patience to compile; Because of this, we have adopted a compromise of separating storyboards as much as possible. The Main. StoryBoard is the top container of the Main frame and the top container of the login process, and the other 3-5 modules are like, Storyboard, Host. Storyboard, minecenter. storyboard, etc., use a separate storyboard file, except that it is written in pure code.





PNG modules.





MainStoryBoard.png





MineCenterStoryBoard.png

In the process of story page separation, it is mainly the process of customizing UITabBarController. First, create a story version file according to the above template. Then drag the specific controller containers, navigation controllers, and view controllers into their storyboards (StoryBoard files), as shown in section 1. Thirdly, in the custom UITabBarController, connect various modules. In this process, UITabBarController plays the role of the connection center of the application. To show off my skills, I made a middle bulge effect, and the main TabBarController code is as follows:

Pragma mark: Home page storyboard
    UIImage *hostSelectImg = [UIImage imageNamed:@"hostViewSelect"];
    UIImage *hostUnSelectImg = [UIImage imageNamed:@"hostViewUnSelect"];
    UIStoryboard *hostSB = [UIStoryboard storyboardWithName:@"Host" bundle:nil];
    UINavigationController *hostNaviVC = [hostSB instantiateViewControllerWithIdentifier:@"hostNavigationC"];
    hostNaviVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@ "home page" image:[self scaleImage:hostUnSelectImg] selectedImage:[self scaleImage:hostSelectImg]];
    hostNaviVC.tabBarItem.tag = 0;

#pragma Mark: Focus on storyboard
    UIImage *attentionSelectImg = [UIImage imageNamed:@"attentionSelect.png"];
    UIImage *attentionUnSelectImg = [UIImage imageNamed:@"attentionUnSelect.png"];
    UIStoryboard *attentionSB = [UIStoryboard storyboardWithName:@"Attention" bundle:nil];
    UINavigationController *attentionNaviVC = [attentionSB instantiateViewControllerWithIdentifier:@"attentionNavigationC"];
    attentionNaviVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@ "concern" image:[self scaleImage:attentionUnSelectImg] selectedImage:[self scaleImage:attentionSelectImg]];
    attentionNaviVC.tabBarItem.tag = 1;

#pragma Mark: Discover storyboards
    UIImage *findSelectImg = [UIImage imageNamed:@"findSelect.png"];
    UIImage *findUnSelectImImg = [UIImage imageNamed:@"findUnSelect.png"];
    UIStoryboard *findSB = [UIStoryboard storyboardWithName:@"Find" bundle:nil];
    UINavigationController *findNaviVC = [findSB instantiateViewControllerWithIdentifier:@"findNavigationC"];
    findNaviVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@ "discovered" image:[UIImage imageWithCGImage:findUnSelectImImg.CGImage scale:1.5 orientation:findUnSelectImImg.imageOrientation] selectedImage:[UIImage imageWithCGImage:findSelectImg.CGImage scale:1.5 orientation:findSelectImg.imageOrientation]];
    [findNaviVC.tabBarItem setImageInsets:UIEdgeInsetsMake(- 14.0.14.0)];
    findNaviVC.tabBarItem.tag = 2;
    findNaviVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"findSelect.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    findNaviVC.tabBarItem.image = [[UIImage imageNamed:@"findUnSelect.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

Pragma mark: Shopping cart storyboard
    UIImage *goodsCarSelectImg = [UIImage imageNamed:@"goodsCarSelect.png"];
    UIImage *goodsCarUnSelectImg = [UIImage imageNamed:@"goodsCarUnSelect.png"];
    UIStoryboard *goodsCarSB = [UIStoryboard storyboardWithName:@"GoodsCar" bundle:nil];
    UINavigationController *goodsCarNaviVC = [goodsCarSB instantiateViewControllerWithIdentifier:@"goodsCarNavigationC"];
    goodsCarNaviVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@" Shopping cart" image:[self scaleImage:goodsCarUnSelectImg] selectedImage:[self scaleImage:goodsCarSelectImg]];
    goodsCarNaviVC.tabBarItem.tag = 3;

#pragma Mark: Personal-centric storyboard
    UIImage *mineCenterSelectImg = [UIImage imageNamed:@"mineCenterSelect.png"];
    UIImage *mineCenterUnSelectImg = [UIImage imageNamed:@"mineCenterUnSelect.png"];
    UIStoryboard *mineCenterSB = [UIStoryboard storyboardWithName:@"MineCenter" bundle:nil];
    UINavigationController *mineCenterNaviVC = [mineCenterSB instantiateViewControllerWithIdentifier:@"mineCenterNavigationC"];
    mineCenterNaviVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@ "me" image:[self scaleImage:mineCenterUnSelectImg] selectedImage:[self scaleImage:mineCenterSelectImg]];
    mineCenterNaviVC.tabBarItem.tag = 4;

# pragma mark: connection
    self.viewControllers = @[hostNaviVC, attentionNaviVC, findNaviVC, goodsCarNaviVC, mineCenterNaviVC];Copy the code

Finally, create the corresponding view controller for each module and match it to the controls in the StoryBoard.





Frame directory.png

3. APP usage process

The typical APP running process is, first execute AppDelegate delegate delegate method didFinishLaunching, enter the startup page, determine if it is the first time to use the APP, if it is the welcome page, otherwise directly verify the AD page validation, then enter the loading AD page, and finally enter the home page. The specific flow chart is as follows:





APP flowchart. PNG

My framework also follows this process.

conclusion

Fearful, treading on thin ice, hope to make persistent efforts, under the project hosting address, EVNEstorePlatform GitHub, if you feel helpful, please do not mean praise, you can give a star on GitHub, O(∩_∩)O thank……