Organize your notes with iOS 10-compatible data

Source: Internet
Author: User
Tags uikit

1.Notification (Notification)

Since the introduction of notification, Apple has been updating the optimization, but these update optimizations are only a few, until now iOS 10 began to really do large refactoring, which allows developers to realize the usernotifications of ease of use, the function has become very powerful.

  • Previous notifications for IOS 9

    1. When calling a method, some methods make it difficult to distinguish and write wrong methods, which makes the developer sometimes very distressed.

    2. The path that the app captures notifications at run time and non-runtime is not consistent.

    3. When applied to the foreground, remote notifications cannot be displayed directly, and further processing is required.

    4. Notifications that have been issued cannot be updated, the content is not changed when it is issued, and only simple text presentation, extensibility is not very good at all.

  • Notifications starting with IOS 10

    1. All relevant notifications have been consolidated into the Usernotifications.framework framework.

    2. Added cancellation, update, mid-way can also modify the content of the notice.

    3. The notification is not a simple text, you can add videos, pictures, custom notification display and so on.

    4.iOS 10 is easier to manage than previous notifications and has been optimized for large scale, which is a good thing for developers.

    5.iOS 10 starting with the optimization of permissions issues, it is easier to request permissions (local and remote notifications are integrated in one method).

  • IOS 10 Notification Learning Related Materials:

    Usernotifications: Apple Official document – Apple official video-Apple official video-Apple official Videos 3

    Https://developer.apple.com/reference/usernotifications

    https://developer.apple.com/videos/play/wwdc2016/707/

    https://developer.apple.com/videos/play/wwdc2016/708/

    https://developer.apple.com/videos/play/wwdc2016/724/

    The reconstruction of –ios-usernotifications frame analysis of live-time-seeing

    https://onevcat.com/2016/08/notification/


    WWDC2016 Session Note –ios 10 push notification new features

    http://www.jianshu.com/p/9b720efe3779

2.ATS problem

The default non-HTTs network in IOS 9 is forbidden, and of course we can also set Nsallowsarbitraryloads to Yes to disable ATS. However, iOS 10 from January 1, 2017 Apple does not allow us to skip ATS through this method, that is, forcing us to use HTTPS, if not, submit the app may be rejected. But we can use Nsexceptiondomains to open HTTP for a specific domain name, which can be easily audited.

Reference study articles are as follows:

Questions about ATS in IOS 10

https://onevcat.com/2016/06/ios-10-ats/

3.iOS 10 Privacy Rights settings

IOS 10 began to more strict privacy rights, if you do not set up will directly crash, and now a lot of crash problems, the general solution is to add the corresponding key–value in the Info.plist file.

Access to the album key was added incorrectly, the correct is the Privacy-photo Library Usage Description.

The value above, circled the red line portion of the text is displayed to the user to see, must be added. At present the solution is basically the same, the reference study article is as follows:

Compatible with iOS 10: Configure the Get Privacy Data permission statement

http://www.jianshu.com/p/616240463a7a

4.Xcode 8 Run a bunch of useless logs solutions

We see, a new project of their own to print a pile of rotten seven or eight bad things, I think this should be the problem of Xcode 8, specifically not detailed research, the solution is to set os_activity_mode:disable such as:

Related Issues Connection:

StackOverflow Quiz

Http://stackoverflow.com/questions/37800790/hide-xcode-8-logs

5.iOS Uistatusbar Method Expires:

Some of the Uistatusbar properties may be used in our development, and these methods have expired in iOS 10 and need to be adapted if they are useful in your project. The above image can also be found, if you need to use Preferredstatusbar in iOS 10 such as:

IOS 10

- (uistatusbarstyle)preferredstatusbarstyle {

return uistatusbarstyledefault;

}

6.iOS Uicollectionview Performance Optimization

With the developer's Trust in Uicollectionview, the project uses a lot of places, but there are still some problems, such as sometimes lag, loading slow and so on. So iOS 10 is further optimized for Uicollectionview because the narrative is more complex and time-consuming, and here are just a few of the Learning reference articles:

WWDC2016 Session note –ios Uicollectionview new features

7.iOS Uicolor New method

The following is an explanation of the official documentation:

Most graphics frameworks throughout the system, including core graphics, core Image, Metal, and avfoundation, with Substan Tially improved support for Extended-range pixel formats and wide-gamut color spaces. By extending this behavior throughout the entire graphics stack, it's easier than ever to support devices with a wide col or display. In addition, UIKit standardizes-working in a new extended sRGB color space, making it easy-to-mix sRGB colors with Colo RS in other, wider color gamuts without a significant performance penalty.

Here is some best practices to adopt as a start working with Wide Color.

  • In IOS, the Uicolor class uses the extended SRGB color space and its initializers no longer clamp raw component values To between 0.0 and 1.0. If your app relies on UIKit to clamp component values (whether "re creating a color or asking a color for its component values), you need to the change your app's behavior when you link against IOS 10.

  • When performing custom drawing in a UIView on an iPad Pro (9.7 inch), the underlying drawing environment is configured wit H an extended SRGB color space.

  • If your app renders custom image objects, use the new Uigraphicsimagerenderer class to control whether the destination bit Map is created using a extended-range or standard-range format.

  • If you is performing your own image processing on wide-gamut devices using a lower level API, such as Core Graphics or Me Tal, you should use an extended range color space and a pixel format that supports 16-bit floating-point component values. When clamping of color values are necessary, you should does so explicitly.

  • Core Graphics, Core Image, and Metal performance Shaders provide new options for easily converting colors and images Betwe En color spaces.

Because before we all use RGB to set the color, anyway, it is not particularly diversified, this new method should be a fix it. So in iOS 10 Apple officially recommends that we use sRGB because of its better performance and richer colors. If you have written a set of classifications for Uicolor, you can also try to replace them with the new two APIs in the Srgb,uicolor class as follows:

+ (uicolor *)colorwithdisplayp3red:(cgfloat)displayp3red Green: (cgfloat)green Blue:(cgfloat)Blue Alpha:( CGFloat)Alpha Ns_available_ios(10_0);

- (uicolor *)initwithdisplayp3red:(cgfloat)displayp3red Green:( CGFloat)green Blue:(cgfloat)Blue Alpha:(cgfloat )Alpha Ns_available_ios(10_0);

8.iOS Uitextcontenttype

The Textcontenttype property was to provide the keyboard with extra information about the semantic intent of the text do Cument.

@Property(nonatomic,copy) uitextcontenttype textcontenttype ns_available_ios (10_0); //default is nil

The Textcontenttype enumeration is added to iOS Uitextfield to indicate the semantic meaning that the text input area expects.

Use this property to give keyboard and system information about the intended semantic meaning of the content that the user enters. For example, you can specify a text field that the user fills in to receive an e-mail confirmation uitextcontenttypeemailaddress. When you provide information about what you expect users to enter in the text input area, the system can automatically select the appropriate keyboard in some cases and improve keyboard corrections and integration with other text input opportunities.

9.iOS 10 fonts change with the font of your phone system

When our phone system font changes, then the label of our app will change along with it, which requires us to write a lot of code for further processing to be implemented, but iOS 10 provides such a property adjustsfontforcontentsizecategory to set. Because there is no real machine, the actual operation has not been realized, if you understand the wrong to help correct.

UILabel *MyLabel = [UILabel New];

/*

Uifont Preferredfontfortextstyle: means specifying a style and letting the font size match the font size set by the user.

*/

MyLabel. Font =[uifont preferredfontfortextstyle: uifonttextstyleheadline];

/*

Indicates whether the corresponding element should automatically update its font when the device ' s uicontentsizecategory I S changed.

For the effect, the element's font must be a font vended using +preferredfontfortextstyle:or +preferred FontForTextStyle:compatibleWithTraitCollection:with a valid Uifonttextstyle.

*/

//Whether to update font changes

MyLabel. Adjustsfontforcontentsizecategory = YES;

10.iOS Uiscrollview New Refreshcontrol

After IOS 10, the refresh feature is supported as long as it inherits Uiscrollview:

@Property (nonatomic, strong, nullable) Uirefreshcontrol * Refreshcontrol Ns_available_ios(10_0) __tvos_prohibited;

11.iOS 10 Judging system version correct posture

Judging the system version is what we often use, especially now everyone may need to adapt to iOS 10, then the problem arises, such as:

We got the answer:

Value of 1

[[[[Uidevice currentdevice] systemversion] substringtoindex:1] integervalue]

Value of 10.000000

[[Uidevice currentdevice] systemversion]. Floatvalue,

Value of 10.0

[[Uidevice currentdevice] systemversion]

Therefore, the best way to judge the system is to use the latter two methods, oh ~ I forgot to say [[Uidevice Currentdevice] Systemversion].floatvalue This method is also not reliable, As if the output of the 8.3 version of the value is 8.2, it is not clear that is not reliable, so we recommend that you use [[Uidevice Currentdevice] systemversion] This method!

Swift judges the following:

If #available (IOS 10.0, *) {

//IOS 10.0

Print("IOS 10.0");

} else { }

Reference articles are as follows:

Common macro definitions for daily work in IOS

Http://www.jianshu.com/p/213b3b96cafe

12.Xcode 8 Plugin Not available problem

Everyone has upgraded Xcode 8, but for developers who rely on plug-ins, cry and go online to find a solution. So here's the workaround:

Let your Xcode8 continue to use the plugin

Http://t.cn/RcSHhSz

But see the article at the end of the explanation, we know that if the use of plug-ins, there may be security problems, and the submission of the audit will be rejected, so it is recommended that you do not use, the solution is always there, such as the code block to add comments in Xcode is also very convenient.

13.iOS 10 Start Project Some text display is not complete problem

I used Xcode 8 and Xcode 7.3 to test the next, such as:

Xcode 8

Xcode 7

Create a label and then make it adaptive size, the font size is 17 the width of the last output is not the same, we look at the following data to know why upgrade iOS 10 after the text in the app is not fully displayed:

Xxode 8 Printing XCODE 7.3 Printing
1 Text width: 17.5 1 Text width: 17
2 Text width: 35 2 Text width: 34
3 Text width: 52 3 Text width: 51
4 Text width: 69.5 4 Text width: 68
5 Text Width: 87 5 Text width: 85
6 Text width: 104 6 Text width: 102
7 Text width: 121.5 7 Text width: 119
8 Text width: 139 8 Text width: 136
9 Text width: 156 9 Text width: 153
10 Text width: 173.5 10 Text width: 170

The English alphabet will also have this problem, I passed the test, and later found that the English alphabet is not a problem, only the Chinese characters have problems. There is currently only one modification control to solve this problem, there is no other good way to solve it.

This article only for the collation of iOS 10 related materials, but also refer to some of the online articles, but also to update other iOS 10 related materials, as well as problems encountered in the development and so on.

IOS 10 Apple Official documentation

Http://t.cn/RcSHb38

Organize your notes with iOS 10-compatible data

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.