Common development skill series (3) and development skill Series
Problems arising from hot updates:
Two days ago, I was talking about the iOS hot update problem. As a result, I hit the gun today. Really! The review is rejected. Of course, this is not a question about RN or JSPath used in my own project. It is a question !! Autonavi updated its SDK as soon as it was pushed out. It was updated only today. That's right! The following are some rejected content of Apple's review. You can give a reference as long as the following types of hot updates are all the latest. What it said is a problem, because the project is native and can only be used by third-party sdks. I checked it online and used this SDK myself!
Well, you can only update the SDK for pushing. This error occurs in the result of Cocopods! [!] Unable to satisfy the following requirements:
You can run the pod update -- verbose command on the terminal on the cd file! (Note: It will take a little longer, so be patient !)
Warning continue:
Warning in Xcode is still annoying! Here are two tips for eliminating warnings!
First, you can use SVN or Git to manage code. If you delete some files that you have created and are useless. There will be a bunch of file missing warnings !!! If you have more than one thousand project warnings like the following, you will be bored!
After xcode8 is upgraded, a bunch of file missing warnings are prompted.
In fact, there is a positive solution at the end of this blog: Xcode-> Preferences-> Source-> Enable Source Control is removed!
Enable Source Control: Enable/disable the built-in Source Control Manager (SCM) of XCode ).
Type 2: This warning has nothing to do with SVN or Git.
For example, the warning during the following comments. I know that the hainfo SDK is indeed a bunch of Chinese comments and then a bunch of English comments. It is understandable that, after all, it is necessary to go global! Okay. Eliminate the warning first.
In this way:
Click the Reveal in Log we selected, and you will see the following text:
As you can see [-Wdeprecated-declrations] under the red line, the method is here. replace-W with-Wno-and remove square brackets. The rest is what we will use, for example, here is:-Wno-deprecated-declrations
Search for Other Waring Flags in the Build Settings of our project and add-Wno-deprecated-declrations. This warning of the deprecated-declrations type will no longer appear.
(Note: The above-Wno-deprecated-declrations are not intended to be entered in the anti-leech SDK warning. I just want to explain the entire operation procedure to you !)
Image stretching:
Let's talk about a message display box that is the most common chat we often see:
We often use the imageView. image attribute that you often see during Stretching. The image here is stretched according to the size of the imageView. We all know this kind of defect will be distorted!
The following three methods are commonly used to stretch images:
/* - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight __TVOS_PROHIBITED - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets NS_AVAILABLE_IOS(5_0); // create a resizable version of this image. the interior is tiled when drawn. - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode NS_AVAILABLE_IOS(6_0); // the interior is resized according to the resizingMode*/
Let's talk about it one by one. We often use the first method to stretch the chat message box. The following is a comparison of code and:
It is explained that the shallow method can be stretched in the range of 1 vertical pixel after leftCapWidth and 1 Horizontal pixel after topCapHeight. For example, the following code copies the pixels with the coordinates (2, 2) from the first 2nd columns on the left and 2nd rows on the top.
UIImage * image1 = [UIImage imageNamed:@"image"]; UIImageView * imageView1 = [[UIImageView alloc]initWithImage:image1]; imageView1.frame = CGRectMake(50, 100, 300, 60); [self.view addSubview:imageView1]; UIImage * image2 = [UIImage imageNamed:@"image"]; image2 = [image2 stretchableImageWithLeftCapWidth:1 topCapHeight:1]; UIImageView * imageView = [[UIImageView alloc]initWithImage:image2]; imageView.frame = CGRectMake(50, 200, 300, 60); [self.view addSubview:imageView];
Let's talk about the second method:
- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets NS_AVAILABLE_IOS(5_0); // create a resizable version of this image. the interior is tiled when drawn
The specific usage is as follows:
UIImage * image1 = [UIImage imageNamed:@"image"];UIImageView * imageView1 = [[UIImageView alloc]initWithImage:image1];imageView1.frame = CGRectMake(50, 100, 300, 60);[self.view addSubview:imageView1]; UIImage * image2 = [UIImage imageNamed:@"image"];image2 = [image2 resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)];UIImageView * imageView = [[UIImageView alloc]initWithImage:image2];imageView.frame = CGRectMake(50, 200, 300, 60);[self.view addSubview:imageView];
Note: (the source image is on the left and the source image is stretched on the right)
Note: The above method requires attention. The default stretch mode used by this method is region replication. It means that the area to be assigned a value is assigned until the display area is satisfied!
The last method requires attention to the following enumeration. You can replace the above method with this to see the effect and understand the difference between this replication and the gradient!
/* UIImage will implement the resizing mode the fastest way possible while retaining the desired visual appearance. note that if an image's resizable area is one point then UIImageResizingModeTile is always indistinguishable from UIImageResizingModeStretch. typedef NS_ENUM (NSInteger, UIImageResizingMode) {UIImageResizingModeTile, // copy the area to be stretched to UIImageResizingModeStretch, // perform gradient stretch on the area to be stretched };*/