iOS8新特性主要体现在4方面

1.UIAlertController 对alert&actionSheet的封装

UIAlertController.h

提示框按钮的选择

typedef NS_ENUM(NSInteger, UIAlertActionStyle) {

UIAlertActionStyleDefault = 0,

UIAlertActionStyleCancel,

UIAlertActionStyleDestructive

} NS_ENUM_AVAILABLE_IOS(8_0);

提示框的样式

typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {

UIAlertControllerStyleActionSheet = 0,

UIAlertControllerStyleAlert

} NS_ENUM_AVAILABLE_IOS(8_0);

NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying>

创建提示框按钮

+ (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

创建提示框

+ (instancetype)alertControllerWithTitle:(NSString *)title message:(NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle;

添加按钮

- (void)addAction:(UIAlertAction *)action;

@property (nonatomic, readonly) NSArray *actions;

添加文本输入框

- (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;

简单实用示例

//    1.创建提示框对象,默认是actionSheet效果

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"注意" message:@"我的呈现方式变了" preferredStyle:UIAlertControllerStyleAlert];

//    2.创建取消按钮并添加到提示框上

[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

NSLog(@"取消按钮被点击了");

}]];

//    3.呈现提示框

[self presentViewController:alert animated:YES completion:nil];

2.UIPopoverController的呈现方式改变不必再像之前那样,直接通过present方式呈现

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);

使用示例

//   1.创建内容控制器

UITableViewController *contentVc = [[UITableViewController alloc] init];

//   2.1 设置呈现方式

contentVc.modalPresentationStyle = UIModalPresentationPopover;

//   2.2设置在导航栏的左边按钮呈现

contentVc.popoverPresentationController.barButtonItem = self.navigationItem.leftBarButtonItem;

//    3.呈现

[self presentViewController:contentVc animated:YES completion:nil];

以前的方式

// 1.创建内容控制器

UITableViewController *contentVc = [[UITableViewController alloc] init];

// 2.创建popover

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:contentVc];

popover.popoverContentSize = CGSizeMake(100, 100);

// 3.呈现

[popover presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

3.获取用户授权的用户隐私保护

地图定位示例:

//导入定位框架

#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<CLLocationManagerDelegate>

//设置定位对象

@property(nonatomic,strong)CLLocationManager* maneger;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

//    当使用iOS8定位的时候需要请求用户授权,且在info.plist里添加字段NSLocationAlwaysUsageDescription 请求用户授权的描述

//    iOS7仅仅需要在info.plist里添加字段Privacy - Location Usage Description 请求用户授权的描述

//    不需要再写下面的代码

if (IOS8) {

[self.maneger requestAlwaysAuthorization];//请求用户授权

}

//    开启定位

[self.maneger startUpdatingLocation];

}

4.针对屏幕适配应运而生的size classes

size classes是为了解决storyboard只能订制一种屏幕样式的问题,它不再是具体的尺寸,而是抽象尺寸

通过宽/高 的compact any regular 组成了九种组合包含了所有苹果设备的尺寸

详情 :http://www.cnblogs.com/lijianyi/p/4288462.html

iOS8 新特性的更多相关文章

  1. iOS8新特性(1)——UIAlertController

    一.iOS8介绍 iOS8 新特性,主要是UI上进行了统一 1.UIAlertController 2.UIPresentaionController:管理所有通过modal出来的控制器(看笔记) 3 ...

  2. ios8新特性widget开发-b

    os8发布已经有一段时间了,伴随着ios8同时也出现了许多新的特性,ios系统将会越来越开放,这是好事.其中一个新特性就是在下拉通知栏里加入了个性的widget,开发者可以自己定义widget的样式内 ...

  3. iOS8新特性

    1. App Extension Programming Guide 2.LocalAuthentication.framework - Touch ID Authentication 3.Local ...

  4. iOS8新特性(1)-UIPopoverPresentationController使用

    从iOS 8开始,苹果提出新的 UIPopoverPresentationController代替UIPopoverController: 新的UIPopoverPresentationControl ...

  5. 利用iOS8新特性计算cell的实际高度

    在计算cell的实际高度是 我们一般是通过计算frame  拿到最底部一个控件的最大Y值从而的到cell 的高度  算来算去  比较麻烦 其实,iOS8已经提供了直接通过Cell高度自适应的方法了,根 ...

  6. iOS iOS8新特性--UIPopoverPresentationController

    1.回顾UIPopoverController的使用,下面这份代码只能在ipad下运行 // 初始化控制器,SecondViewController类继承自UIViewController Secon ...

  7. iOS8新特性之基于地理位置的消息通知UILocalNotification

              苹果在WWDC2014上正式公布了全新的iOS8操作系统. 界面上iOS8与iOS7相比变化不大,只是在功能方面进行了完好.                             ...

  8. iOS8新特性之交互式通知

    目前分为四个推送:用户推送,本地推送,远程推送,地理位置推送. if (IS_IOS8) { //1.创建消息上面要添加的动作(按钮的形式显示出来) UIMutableUserNotification ...

  9. Ios8新特性-应用程序扩展

    一.什么是应用程序扩展? 应用程序扩展不是一个应用,它是主体应用程序(containing app)中一个单独的包,并能生成单独的二进制文件供其他应用调用. 个人感觉,类似于WP中的启动器,把系统当个 ...

随机推荐

  1. 【JDK】JDK源码分析-TreeMap(2)

    前文「JDK源码分析-TreeMap(1)」分析了 TreeMap 的一些方法,本文分析其中的增删方法.这也是红黑树插入和删除节点的操作,由于相对复杂,因此单独进行分析. 插入操作 该操作其实就是红黑 ...

  2. 【iOS】获取项目名和版本号

    iOS 开发中,有时候需要获取项目名和版本号,示例代码如下: -(void)getProjectNameAndVersion{ appName = [[[NSBundle mainBundle] in ...

  3. Java基础之二十 并发

    20.1 并发得多面性 并发编程令人困惑的一个主要原因:使用并发时需要解决的问题有多个,而实现并发的方法也有多种,并且在这两者之间没有明显的映射关系. 20.1.1 更快的执行 速度问题初听起来很简单 ...

  4. Linux基础用户管理

    一.用户管理 (一).用户和组的基本概念 Users and groups:. Every process (running program) on the system runs as a part ...

  5. JavaFX 集成 Sqlite 和 Hibernate 开发爬虫应用

    目录 [隐藏] 0.1 前言: 0.2 界面 0.3 Maven 环境 0.4 项目结构 0.5 整合 Hibernate 0.5.1 SQLiteDialect.java 数据库方言代码 0.5.2 ...

  6. 【游记】NOIP2019前传

    声明 我的游记是一个完整的体系,如果没有阅读过往届文章,阅读可能会受到障碍. ~~~上一篇游记的传送门~~~ 前言 比完赛后,我沉浸在胜利中长达半个月,而后才清醒过来,意识到自己需要为NOIP2019 ...

  7. lxml解析网页

    目录 1. 什么是lxml 2. 初次使用 3. xpath 3.2 标签定位 3.3 序列定位 3.4 轴定位 4. 实例 1. 什么是lxml lxml是干什么的?简单的说来,lxml是帮助我们解 ...

  8. cmd命令行界面运行python脚本显示的中文不正确

    在notepad++中编写了一个脚本(如图一),在cmd命令行界面中运行却发现显示的中文不正确(如图2).图3显示的是cmd界面的默认编码. 解决方案:将脚本的注释语言改为GBK,编码格式改为ANSI ...

  9. Android UI控件常用库汇总

    现在App的开发已经是非常成熟,涌现了一大批开源的工具.这些项目能够提高我们的搬砖效率.以下是一些在开发中比较常使用的控件和库. ListView WaveSwipeRefreshLayout 水滴效 ...

  10. SQL Server检索存储过程的结果集

    目的:检索过滤执行存储过程的结果集 如下介绍两个常用的方法,但是都需要申明表结构:不知道是否有更简便的方法,如有更好的方法,请不吝赐教. 以系统存储过程sp_who2为例: 方法1:使用临时表 --1 ...