The new features of iOS8 are mainly embodied in 4 aspects
1.UIAlertController Package for Alert&actionsheet
UIAlertController.h
Selection of the Cue box button
typedef ns_enum (Nsinteger, Uialertactionstyle) {
Uialertactionstyledefault = 0,
Uialertactionstylecancel,
Uialertactionstyledestructive
} ns_enum_available_ios (8_0);
Style of the Cue box
typedef ns_enum (Nsinteger, Uialertcontrollerstyle) {
Uialertcontrollerstyleactionsheet = 0,
Uialertcontrollerstylealert
} ns_enum_available_ios (8_0);
Ns_class_available_ios (8_0) @interface Uialertaction:nsobject <NSCopying>
Create a prompt Box button
+ (Instancetype) Actionwithtitle: (NSString *) Title style: (Uialertactionstyle) style handler: (void (^) (uialertaction * Action)) handler;
@property (nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) Uialertactionstyle style;
@property (nonatomic, getter=isenabled) BOOL enabled;
@end
Ns_class_available_ios (8_0) @interface Uialertcontroller:uiviewcontroller
Create a prompt box
+ (Instancetype) Alertcontrollerwithtitle: (NSString *) title message: (NSString *) message Preferredstyle: ( Uialertcontrollerstyle) Preferredstyle;
Add button
-(void) Addaction: (uialertaction *) action;
@property (nonatomic, readonly) Nsarray *actions;
Add a text input box
-(void) Addtextfieldwithconfigurationhandler: (void (^) (Uitextfield *textfield)) Configurationhandler;
@property (nonatomic, readonly) Nsarray *textfields;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *message;
@property (nonatomic, readonly) Uialertcontrollerstyle Preferredstyle;
Simple and practical example
1. Create a Cue box object, default is Actionsheet effect
Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "note" message:@ "My rendering has changed" PreferredStyle: Uialertcontrollerstylealert];
2. Create a Cancel button and add it to the prompt box
[Alert addaction:[uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel handler:^ (UIAlertAction * Action) {
NSLog (@ "Cancel button was clicked");
}]];
3. Render the Prompt box
[Self Presentviewcontroller:alert animated:yes completion:nil];
The 2.UIPopoverController rendering change does not have to be presented directly in the present way, as before
UIViewController.h
typedef ns_enum (Nsinteger, Uimodalpresentationstyle) {
Uimodalpresentationfullscreen = 0,
Uimodalpresentationpagesheet Ns_enum_available_ios (3_2),
Uimodalpresentationformsheet Ns_enum_available_ios (3_2),
Uimodalpresentationcurrentcontext Ns_enum_available_ios (3_2),
Uimodalpresentationcustom Ns_enum_available_ios (7_0),
Uimodalpresentationoverfullscreen Ns_enum_available_ios (8_0),
Uimodalpresentationovercurrentcontext Ns_enum_available_ios (8_0),
uimodalpresentationpopover Ns_enum_available_ios (8_0),
Uimodalpresentationnone Ns_enum_available_ios (7_0) =-1,
};
@property (nonatomic,readonly) Uipopoverpresentationcontroller *popoverpresentationcontroller NS_AVAILABLE_IOS (8_0 );
Using the example
1. Create a content Controller
Uitableviewcontroller *CONTENTVC = [[Uitableviewcontroller alloc] init];
2.1 Setting the Rendering method
Contentvc.modalpresentationstyle = Uimodalpresentationpopover;
2.2 Setting the left button on the navigation bar renders
ContentVc.popoverPresentationController.barButtonItem = Self.navigationItem.leftBarButtonItem;
3. Rendering
[Self PRESENTVIEWCONTROLLER:CONTENTVC animated:yes completion:nil];
The way it used to be
1. Create a content Controller
Uitableviewcontroller *CONTENTVC = [[Uitableviewcontroller alloc] init];
2. Create PopOver
Uipopovercontroller *popover = [[Uipopovercontroller alloc] INITWITHCONTENTVIEWCONTROLLER:CONTENTVC];
Popover.popovercontentsize = cgsizemake (100, 100);
3. Rendering
[PopOver PresentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem permittedarrowdirections: Uipopoverarrowdirectionany Animated:yes];
3. Get user-authorized User Privacy protection
Map Location Example :
Import a positioning frame
#import <CoreLocation/CoreLocation.h>
@interface Viewcontroller () <CLLocationManagerDelegate>
Set anchored objects
@property (Nonatomic,strong) cllocationmanager* Maneger;
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Request user authorization When using IOS8 location, and add field in Info.plist nslocationalwaysusagedescription Request user Authorization description
IOS7 only need to add fields in Info.plist privacy-location Usage Description Request User Authorization description
No need to write the following code
if (IOS8) {
[Self.maneger requestalwaysauthorization];//requesting user authorization
}
//Open position
[Self.maneger startupdatinglocation];
}
4. Size classes for screen adaptation
Size classes is to solve the problem that storyboard can only customize a screen style, it is no longer the specific size, but the abstract size
Nine combinations of all Apple devices are included with the wide/high compact any regular
Details: http://www.cnblogs.com/lijianyi/p/4288462.html
IOS8 new Features