Tips and ideas for improving the efficiency of IOS development _ios

Source: Internet
Author: User
Tags uikit

Start with a picture of the knowledge system you should learn about iOS development:

1. Full picture As a background, you may encounter problems. , sliding back, the picture stopped for a while before slipping back.

Reason: This kind of interface generally uses the third kind of filling method of general use ImageView.

This type of padding allows the image to be compressed without compression, as much as possible to fill the entire control, but when you set the enumeration's fill mode, remember to follow the following figure to cut out the scope of the control


When you set a constraint, remember to choose the CurrentView object


2. The problem of equipment adaptation

or above this picture, in accordance with the design of 6p above to set automatic constraints, about good, in 5s above the time, the following love in the setting of automatic constraints and professional settings too close, this time quite affect the beautiful, this time the first reaction of course is based on equipment to adjust, But I think it's perfectly possible to use the following method to determine the setting

 CGFloat top = 0;
  CGFloat left = 0;
  CGFloat bottom = 0;

  CGFloat right = 0;
    if ([uiscreen ff_screensize].width = = 375) {top = 80;
    left = 70;
    bottom = 31;
    Self.titleLabel.font = [Uifont systemfontofsize:18];
    Self.englishLabel.font = [Uifont systemfontofsize:20];
    Self.introduceLabel.font = [Uifont systemfontofsize:14];

  right = 33;
    }else if ([uiscreen ff_screensize].width = = 414) {bottom = 31;
    top = 88;
    left = 84;

  right = 33;
    }else if ([UIScreen ff_screensize].width =) {Self.titleLabel.font = [Uifont systemfontofsize:16];
    Self.englishLabel.font = [Uifont systemfontofsize:18];
    Self.introduceLabel.font = [Uifont systemfontofsize:13];
    Self.introduceTop.constant = 8;
    top = 70;
    left = 44;
    bottom = 24;

  right = 28;

  } self.collectionButtonLeft.constant = right;
  Self.chineseLabelTop.constant = top;
  Self.introlduceLeft.constant = left;

  Self.collectionButtonbottom.constant = bottom; [SELf.view Setneedslayout]; 

Remember to change the constraint [self.view setNeedsLayout]; and call it. This is also a key point, do not invoke no effect.

3. Digital animation effect


When it comes to data with large numbers, you can take this effect to do, the effect is moving.
To achieve this effect is also relatively simple.

@property (Weak, nonatomic) Iboutlet Uicountinglabel *tuitionlabel;

 WeakSelf.tuitionLabel.text = self.tuitionForAcademyModel.tuition;

Nsinteger grade = [Self.tuitionForAcademyModel.tuition integervalue];

WeakSelf.tuitionLabel.format = @ "%d%";

[Weakself.tuitionlabel Countfromzeroto:grade];

The most important step is to set the format, otherwise he will run decimal.

How 4.label text spacing adjusts

-(void) Configurecontentlabeltext
{
  nsmutableattributedstring *attributedstring = [ Nsmutableattributedstring alloc]initwithstring:@ "Label"];
  Long number = 5;
  Cfnumberref num = cfnumbercreate (kcfallocatordefault,kcfnumbersint8type,&number);
  [Attributedstring AddAttribute: (ID) kctkernattributename value: (__bridge ID) num Range:nsmakerange (0,[ Attributedstring length])];
  Cfrelease (num);

  Self.label.attributedText = attributedstring;
}

The effect is as follows, the spacing of the word is opened


5. Login Ideas

A. After the user enters the app, in the process of using the app, the operation that needs to login is done.

B. The backend interface that is invoked at this time typically requires a token parameter to be taken. This time because the user did not login, there is no token, so here to determine whether the local persistence of token.

C. There is no persistent token locally, so automatically eject the login box to allow users to log in

D. Local persistence of relevant data, especially token, after the user has logged in

Small details:

A. Each time you start the app, you can read the token IO operation and save it in a single case so that you don't have to repeat the performance-intensive IO operation.

B. Because custom controls are essential in a project, at the control-level page, you need to use an operation that requires a login, and you need to send a notification to the corresponding controller to present the login controller because the controller level can eject the controller, so will produce a large number of notification operations, it is recommended that login can be written on the window (here because the project duration is tight, found that the problem has been difficult to deal with, I hope later brothers remember)

C. The interface that needs token parameter, token parameter error, this time need to give a unified callback in the background, so convenient to concentrate to handle

6. The idea of the account playing with each other

Never try to work on a single page.

Ideas are as follows:

1. The need to log out of the notification to the various controllers, and in the notification of each controller initialization operation.

2. When calling the interface that needs to be logged in to operate, the background is judged to give you a callback that token parameter invalidation

3. As a reasonable project framework, there should always be a AFN package! In the package of AFN inside the unified judgment, the following figure. (Because each background processing is different, the code on the diagram, give you the code can not be reused.) )


4. This notification is sent to the Uitabbarcontrollerto allow the user to log on again

#import <UIKit/UIKit.h>

@interface wxmaincontroller:uitabbarcontroller

@end
#pragma mark-listen to each other, and then exit the login and return to the home page-(void) addnotification{WS (weakself);
  [[Nsnotificationcenter Defaultcenter] postnotificationname:kmutualkicknotification Object:nil]; [[Nsnotificationcenter Defaultcenter] addobserverforname:kmutualkicknotification object:nil queue:nil usingBlock:^ (

  Nsnotification * _nonnull Note) {[weakself Alertwindow];

}];

    #pragma mark-Pop-up selection interface-(void) alertwindow{if (!self.isshow) {self.isshow = YES; Uialertview *alter = [[Uialertview alloc] initwithtitle:@ "message:@" Your account has been logged on to another device and you are now logged out of the login status "delegate:self

    cancelbuttontitle:@ "determine" otherbuttontitles:nil];
  [Alter show]; } #pragma mark-pop-up box to select the proxy method for the interface, click OK to eject the login box-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) buttonindex{if (Buttonindex = = 0) {Wxlogincontroller * Logincontroller = [Wxlogincontroller showlogincontoller:n

    O Andisshowcolse:no];

    [Self Presentviewcontroller:logincontroller animated:yes completion:nil]; SelF.isshow = NO; }

}

Everything has methods and skills, no shortcuts, iOS development is no exception, down-to-earth from the practice of discovering methods, skilled after the skills. Hopefully this article will help you learn about iOS development for everyone.

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.