The iOS 10 development update focuses on the following aspects.

1. Speech recognition Apple officially added API Speech in the document, so in the past, we may need to use a third-party framework to deal with Speech recognition is very cumbersome, so after Apple launched this, we will be very convenient to process, Speech has the following characteristics:

  • Continuous speech recognition can be achieved
  • Voice files or voice streams can be identified
  • Optimizes free-form dictation (understood as multi-language support) and searchable strings

Core code:

#import /** voice recognition also needs to be tested on the real machine, because it needs hardware support, and also needs access rights */ //1. Create localized identifier NSLocale * local = [[NSLocale alloc] initWithLocaleIdentifier: @ "zh_CN"]. SFSpeechRecognizer *sf =[[SFSpeechRecognizer alloc] initWithLocale:local]; NSURL *url =[[NSBundle mainBundle] URLForResource:@" I love you "withExtension:nil]; / / 4. Pass resource package for the url of the request object SFSpeechURLRecognitionRequest * res = [[SFSpeechURLRecognitionRequest alloc] initWithURL:url]; / / 5. Send a request [sf recognitionTaskWithRequest: res resultHandler: ^ (SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) { if (error! = nil) {NSLog (@ "speech recognition resolution fail, % @," error ");} else {/ / parse correctly NSLog (@ "- % @", result, bestTranscription. FormattedString);}}];Copy the code

2. Improvements in UITabBarController before iOS 10, the default color of text on tabBarItem was blue, the new message on it reminded the digital Badge was red by default, and the default color of text on the unselected tabBarItem was black. If we modify it, You can only change the default color, and you can’t customize anything else, which is very inconvenient to use, but with iOS10 we can easily customize it.

Core code:

OneViewController *oneVc =[[OneViewController alloc] init]; / / 2. Each set on the controller tabbar oneVc. The backgroundColor = [UIColor redColor]; // set the title onevc.tabbarItem. title = @" home "; TwoViewController *twovC =[[TwoViewController alloc] init]; twovC.view.backgroundColor =[UIColor purpleColor]; // Set the title twovc.tabbarItem. title = @" circle "; ThreeViewController *threVC =[[ThreeViewController alloc] init]; threVC.view.backgroundColor =[UIColor blueColor]; // set the title threvc.tabbaritem. title = @" social "; / / 2. The three common controller to join tabbarController will create good controller [self addChildViewController: oneVc]; [self addChildViewController:twovC]; [self addChildViewController:threVC]; / / change the default color words above the tabbar oneVc tabBarController. Tabbar. TintColor = [UIColor yellowColor]; twovC.tabBarController.tabBar.tintColor =[UIColor yellowColor]; threVC.tabBarController.tabBar.tintColor =[UIColor yellowColor]; // This line of code changes the default color of tabbar unchecked -- black -- to red oneVc.tabBarController.tabBar.unselectedItemTintColor =[UIColor redColor]; / / tabbarItem attribute / / digital remind in color 10 prior versions of the default in the iOS are digital remind are red oneVc. TabBarItem. BadgeColor = [UIColor orangeColor]; oneVc.tabBarItem.badgeValue =@"90"; / / will be digital tabBarItem remind to change the default white Using rich text changes [oneVc tabBarItem setBadgeTextAttributes: @ {NSForegroundColorAttributeName: [UIColor blackColor] } forState:UIControlStateNormal];Copy the code

In the past, if we want to change the font size of the APP program, we can only customize the font or use runtime for processing, or have to set UIFont, very inconvenient, from iOS10 Apple officially allow us to customize the Settings

Core code:

/* In iOS 10, when we users set the font size of the phone, then the app will set the relevant code font will also change, support some common font UI controls such as UILabel UIButton **/ [super viewDidLoad]; / / set the change of the font size of the self. The labels. The font = [UIFont preferredFontForTextStyle: UIFontTextStyleBody]; / / allow change / * tell you must clearly apple and preferredFontForTextStyle or preferredFontForTextStyle style: (nsstrings *) To combine compatibleWithTraitCollection Note here does not support the simulator operations * * / self. Labels. AdjustsFontForContentSizeCategory = YES;Copy the code

Before iOS 10, we used UIView to make animation effects or customize some layer animations. If we started, we generally could not stop the operation, let alone suspend the operation, and some very complicated animation processing was also quite troublesome. But in iOS10, Apple has removed a new API UIViewPropertyAnimator that allows us to handle animation operations. UIViewPropertyAnimator is a new class in iOS10 that performs View animations. It has the following features:

  • Interruptible sex
  • Can be erased
  • Reversible sex
  • Rich animation time control function

Official documentation: Snip20160618_30.pngSnip20160618_31.png

Core code:

#import "ViewController.h" @interface ViewController () @property(nonatomic,strong)UIView *myView; @property(nonatomic,strong)UIViewPropertyAnimator *myViewPro; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIView *Views =[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; Views.backgroundColor =[UIColor yellowColor]; [self.view addSubview:Views]; //2. Create an external variable to reference self.myView = Views; / / 3. Create a view animation editor UIViewPropertyAnimator * viewPro = [UIViewPropertyAnimator runningPropertyAnimatorWithDuration: 1.0 Delay: 30.0 options: UIViewAnimationOptionCurveLinear animations: ^ {/ / use the View animation, modify the View frame self. MyView. Frame = CGRectMake(230, 230, 130, 130); } completion:nil]; self.myViewPro = viewPro; } // end - (IBAction)stop:(id)sender{// YES and NO apply to setting whether the current property animator can continue to use [self.myViewPro stopAnimation:YES]; } // continue - (IBAction)continued:(id)sender {//UITimingCurveProvider /** @property(nullable, nonatomic, readonly) UICubicTimingParameters *cubicTimingParameters; @property(nullable, nonatomic, readonly) UISpringTimingParameters *springTimingParameters; */ / The value of the basket is 0. The farther near zero so the more pronounced the UISpringTimingParameters * sp = [[UISpringTimingParameters alloc] initWithDampingRatio: 0.01]; UICubicTimingParameters *cub =[[UICubicTimingParameters alloc] initWithAnimationCurve:UIViewAnimationCurveEaseInOut]; / / durationFactor to a default value of 1 can be [self. MyViewPro continueAnimationWithTimingParameters: sp durationFactor: 1.0]; } // pause - (IBAction)puase:(id)sender {[self.myViewPro pauseAnimation]; } // start - (IBAction)start:(id)sender {[self.myviewpro startAnimation]; }Copy the code

Effect: Before iOS10, UIColor set color can only be represented by RGB, in iOS native does not support #16 notation, but also have to write their own classification to deal with, we know that RGB color is priority, and is not accurate, So in iOS10, apple officially added the colorWithDisplayP3Red method.

Core code:

+ (UIColor*)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0); // The method can now set the color more accurately.Copy the code

Before iOS 10.0, if we wanted to open a web page or jump to a page using an application, The [[UIApplication sharedApplication] openURL method can be used directly, but it has been deprecated in iOS 10, because using this method, the result of processing can not be intercepted or retrieved, which is very bad for development. In iOS 10 new out of the [[UIApplication sharedApplication] openURL: nil options: nilcompletionHandler: nil]; have a successful callback block can be monitored.

Apple’s official explanation: Options :nil completionHandler:^(BOOL success /* // options are specified in the section below for openURL options. An empty options dictionary will result in the same // behavior as the older openURL call, aside from the fact that this is asynchronous and calls the completion handler rather // than returning a result. // The completion handler is called on the main queue.

Core code:

 [[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success) {  
}];Copy the code

SiriKit is available in iOS 10 to developers using the Siri SDK, which is undoubtedly the most important SDK for iOS 10. Developers can now use native apis to provide voice search, voice-to-text messaging, and more common voice features.

7.User Notifications is an API that allows you to handle local or remote User Notifications based on conditions such as time or geographic location. It seems to intercept and replace the payload sent from your app, and the native notification framework of previous SDK versions has been deprecated, as mentioned in the last post and the code is shown.

Following the launch of VoIP certificate by Apple in 2014, the opening of VoIP interface and a new App Extension are the Gospel of VoIP, which shows that Apple attaches importance to VoIP. The CallKit framework VoIP application integrates with the iPhone user interface to give users a great experience. Use this framework to allow users to view and answer calls on the lock screen and VoIP manage contact calls in the phone APP’s favorites and historical view. Callkit also introduces an extension to the application to enable call blocking and call recognition. You can create an application extension that can associate a phone number with a name or tell the system when a number should be blocked.

9. The improvement of the third-party keyboard is very, very important. The third-party keyboard has not been very convenient to have the function of long pressing the earth key, now it has. Through handleInputModeListFromView: withEvent: can pop-up keyboard list system. Using documentInputMode to detect the language in the context of the input, you can make some adjustments to the input like alignment.

IOS10 privacy permission management such as access to the camera, microphone and other hardware, need to request application permission in advance, allow can be used, or now to declare in advance, although the past requirements are not strict. In iOS10, for example, you have a crash.

Crash log:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data. You will have to stay in the info. Add a NSContactsUsageDescription Key file, the Value add a description. PNG video playback needs to be configured in info.plist. This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSAppleMusicUsageDescription key with a string value explaining to the user how the app uses this data. Access to the user’s private data, and not to the user, must in the plist (info. Plist) configured in this key NSAppleMusicUsageDescription and explain to the user. FFF. PNG

Be careful when opening the project on Xcode8, especially for xiB process. Do not click save at will after the change, otherwise when you open it with Xcode7, you will find an error, and xiB saved by Xcode will not be recognized on Xcode7!

12.ApplePay

  • Can be used for SFSafariViewController
  • Can be used in Extensions without a UI
  • ApplePay is also supported in the iMessage app

CoreData improves concurrent access performance

14. Refresh Control (UIRefresh Control) the refresh Control system at the iOS support all the UIScrollView and its subclasses, such as UICollectionView, UITableView.

Core code:

#import @class UIRefreshControl; NS_CLASS_AVAILABLE_IOS(10_0) @protocol UIRefreshControlHosting @property (nonatomic, strong, nullable) UIRefreshControl *refreshControl __TVOS_PROHIBITED; @endCopy the code

Xcode 8 new features (working on it)

Xcode8 FAQ:

1. Update Xcode 8 card in “Installing…” : I reinstalled my unlimited card three times in a row at “5 minutes to go…” Finally, in the roughest and most direct way, Finder –> Apps, uninstall Xcode 7.3 and install Xcode 8 directly from the AppStore.

2. The console prints redundant project tracking information that appears to be xcode’s own. The following information will be printed on the console after each project is run




Console redundant printing.png


To disable the Xcode Debug Console method: Product –> Scheme –> Edit Scheme Select run from the displayed window. In the Environment Variables area, set OS_ACTIVITY_MODE to “disable” and close.




Console environment variable.png


$sudo /usr/libexec/xpccachectl $sudo /usr/libexec/xpccachectl $sudo /usr/libexec/xpccachectl $sudo /usr/libexec/xpccachectl