The development ofTips
CABasicAnimation
The animation disappears after entering the background
The interface transition animation in the project was created by Using CABasicAnimation. During the test, it was found that when the animation appeared, if you put the APP in the background for a while and then enter the background, the animation would disappear. After searching for information, it was found that CABasicAnimation had an attribute, RemovedOnCompletion, the default value of this property is YES. Looking at the system API, there is a description of this property: When you set this value to YES, the animation will be deleted once the duration of the animation activity has passed. Therefore, we assume that this is the reason why the animation is removed in the background. After setting this property to NO, the animation can play normally. The specific code is as follows, record the problems encountered.
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; Animation. Duration = 1.0; animation.fromValue = @1; Animation. ToValue = @ 0.1; animation.repeatCount = MAXFLOAT; animation.removedOnCompletion = NO; [dot addAnimation:animation forKey:nil];Copy the code
Code snippet
useOC
Write theCRC
16MODBUS
check
+ (NSString *)getCrc16_MODBUSWithString:(NSString *)str{ NSArray *array = [[NSArray alloc]initWithArray:[self seperateStr:str byLength:2]]; unsigned short tmp = 0xffff; unsigned short ret1 = 0; Byte buff[10240] = {}; for (int i = 0; i < array.count; i++) { buff[i] = [[self decimalStringFromHexString:array[i]] intValue]; } for(int n = 0; n < array.count; n++){ tmp = buff[n] ^ tmp; for(int i = 0; i < 8; */ if(TMP & 0x01){TMP = TMP >> 1; tmp = tmp ^ 0xa001; } else{ tmp = tmp >> 1; / / printf(" %X\n", TMP); / / printf(" %X\n", TMP); /* Switch the CRC bits */ ret1 = TMP >> 8; ret1 = ret1 | (tmp << 8); Printf (" ret: %X\n",ret1); NSString *returnStr = [NSString stringWithFormat:@"%X",ret1]; return [self addZero:returnStr withLength:4]; } + (NSMutableArray *)seperateStr:(NSString *) STR byLength:(int)length{// example 828384 split NSMutableArray in two units *returnArray = [[NSMutableArray alloc] init]; for (int i = 0; i < (str.length - length) + 1; i=i+length) { NSString *twoStr = [str substringWithRange:NSMakeRange(i, length)]; [returnArray addObject:twoStr]; } return returnArray; } + (NSString *)decimalStringFromHexString:(NSString *)string{ NSString * decimalStr = [NSString StringWithFormat: @ "% lu", strtoul ([string UTF8String], 0 16th)]; return decimalStr; } + (NSString *)addZero:(NSString *) STR withLength:(int)length{NSString *string = nil; if (str.length==length) { return str; } if (str.length<length) { NSUInteger inter = length-str.length; for (int i=0; i< inter; i++) { string = [NSString stringWithFormat:@"0%@",str]; str = string; } } return string; }Copy the code
CRC-32 MPEG-2
C
Language implementation
Call + (NSString *)getCrc32_mpegWithString:(NSString *) STR {NSArray *array = [[NSArray alloc]initWithArray:[self seperateStr:str byLength:2]]; Byte buff[10240] = {}; for (int i = 0; i < array.count; i++) { buff[i] = [[self decimalStringFromHexString:array[i]] intValue]; // Unsigned int CRC; // unsigned int CRC; crc = do_crc(buff, (int)array.count); printf("CRC-32/MPEG-2 : %x\n", crc); /* Ret1 = CRC >> 8; // ret1 = ret1 | (crc << 8); // printf(" ret: %X\n", CRC); NSString *returnStr = [self addZero:[NSString stringWithFormat:@"%X",crc] withLength:8]; return returnStr; } // unsigned int do_crc(unsigned char * PTR, int len) {unsigned int I; unsigned int crc = 0xFFFFFFFF; while(len--) { crc ^= (unsigned int)(*ptr++) << 24; for (i = 0; i < 8; ++i) { if (crc & 0x80000000) crc = (crc << 1) ^ 0x04C11DB7; else crc <<= 1; } } return crc; }Copy the code
Learning materials
- Open source components and libraries
Address: iosexample.com
Address: www.cocoacontrols.com
Swift
Integrate related third-party resources
Address juejin. Cn/post / 684490…
Awesome iOS
The biggest feature is large and comprehensive, including from development, debugging to releaseApp Store
It also includes recommendations for blogs, books, tutorials, email feeds, and podcasts.
Address nshipster.com/
Swift
Integrate related third-party resources
Address juejin. Cn/post / 684490…
Tools recommended
SM.MS
Address sm. Ms
A tool for converting local images to web images, suitable for daily note-taking using Markdown to display images
TinyPNG
Address tinypng.com/
A picture compression tool, is lossless compression oh, the author in the process of project development, often use the tool to compress the resources of the project picture, easy to use
stream
Address apps.apple.com/cn/app/stre…
Packet capture tool, very easy to use, you can view the request parameters, response results, and set the filter conditions to filter caught interface, export response results, etc.
Lookin
Address lookin. Work /
Lookin allows you to view and modify UI objects in iOS apps, similar to Xcode’s UI Inspector or Reveal.
But Lookin can also debug outside of the UI, thanks to its “console” and “method listener” features. Also, while Lookin is a macOS App, it can be embedded in your iOS App and run on an iPhone or iPad. Finally, Lookin is completely free.
- Peck curtain bird
Address mp.weixin.qq.com/s/ZLeeI0N00…
Youku open source iOS development improvement tool peck screen bird, packet capture, check buried points, visual walk are very convenient, from the case can also locate problems at any time, can help you improve the efficiency of finding problems. Product, test, operations, UED, and developer.