I have been too busy recently. I have been catching up with the schedule and haven’t sent a brief book for a long time.

This time I’ll write about some of the small details I encountered during the project. And interview questions that a lot of people can’t answer.



Simulator Screen Shot July 14, 2016 PM 2.15.26.png

1. Possible problems when the full picture is used as the background. When you slide back, the image stays for a while before sliding back.

Reason: This kind of interface usually uses the third filling method of imageView.




002EA243-E6B5-4081-8D7B-6802DA4D3664.png

This fills the entire control as much as possible without compressing the image, but when setting the enumeration, remember to set it as shown in the following image to cut out the contents that are outside the control




7E3CC90B-26B5-4606-9320-DA6C8EAD05D5.png

When you set the constraint, remember to select the object that’s currentView




7E33C948-E0E1-41D0-8351-DEC97A5B3784.png

2. Device adaptation

Or the picture above, according to the design to set the automatic constraint on 6 p, after an appointment, on 5 s, the love under the automatic constraint set, and professional set too close, very affect beautiful at this time, this time the first reaction is adjusted according to the equipment, of course, but I think here can use this way to determine the Settings below

 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 == 320){

        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];Copy the code

Remember to modify the constraint by calling [self.view setNeedsLayout]; This is also a key point, not to call no effect.

3. Digital animation effects




Entertaining diversions. GIF

When it comes to large numbers of data, this effect can be adopted to do so, and the effect is touching. It’s easy to do that. Third party framework under the address github.com/dataxpress/…

@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];Copy the code

The most important step is to set the format, otherwise it will run decimals.

4. How to adjust the text spacing of label

- (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;
}Copy the code

The effect is that the space between the words is widened




B02489FA-EE29-42AA-8E9D-C5DD5F65FD8B.png

B: No, I don’t think so.

A. After the user enters the APP, the user performs the login operations during the app use. B. In this case, the invoked background interface generally needs to carry the token parameter. In this case, the user does not log in and does not have a token. Therefore, the user checks whether token.c is persisted locally. The local token is not persistent. Therefore, a login dialog box is displayed for the user to log in. After a user logs in, the relevant data, especially the token, is persisted locally

The small details:

A. Each time the app is started, the TOKEN IO operations can be read out and saved in the singleton, so that there is no need to repeatedly perform performance-consuming IO operations B. Because the custom control is essential in the project, in the control level page, you need to use the operation that requires login, at this time, you need to send a notification to the corresponding controller to present login controller, because the controller level can pop up the controller, in this way, a large number of notification operations will be generated. It is recommended to write login above window (it is difficult to deal with this problem when we find it because of the tight project period, we hope our brothers will remember it later) C. If the token parameter is incorrect, a unified callback is required in the background for centralized processing

6. The idea of account kicking each other (this basically the interview of the brothers did not answer)

Don’t try to do this on a single page.

The roadmap is as follows: 1. You need to send a notification to each controller during login and logout and initialize each controller in the notification.

2. When invoking an interface that requires login to operate, the background checks and gives you a callback that the token parameter is invalid

3. As a reasonable project framework, there should be an AFN package. Unified judgment is made in encapsulated AFN, as shown in the following figure. (Because each background processing is not the same, the code on the picture, to your code can not be reused.)




5DE7C264-F0E4-4228-BC2B-6704846DDECA.png

4. This notification is sent to the UITabBarController for the user to log in again

#import 

@interface WXMainController : UITabBarController

@endCopy the code
#pragma mark - (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- pragma mark- (void)alertWindow{if (! self.isShow) { self.isShow = YES; UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"" message:@" "Delegate :self cancelButtonTitle:@" Ok" otherButtonTitles:nil]; [alter show]; }} #pragma mark- popup to select the interface of the proxy method, - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{if (buttonIndex == 0)  { WXLoginController * loginController = [WXLoginController showLoginContoller:NO andIsShowColse:NO]; [self presentViewController:loginController animated:YES completion:nil]; self.isShow = NO; }}Copy the code