yanx730 / yanx730.github.io

Leox' A&i
GNU General Public License v2.0
0 stars 0 forks source link

App Programming Guide for iOS #52

Open yanx730 opened 7 years ago

yanx730 commented 7 years ago

https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007072

yanx730 commented 7 years ago

@1209 看了目录,这个文章值得多看!讲了开发的一些基础知识

yanx730 commented 7 years ago

Introduction

At a Glance

Apps Are Expected to Support Key Features -> Expected App Behaviors Apps Follow Well-Defined Execution Paths -> The App Life Cycle, Strategies for Handling App State Transitions Apps Must Run Efficiently in a Multitasking Environment -> Background Execution, Strategies for Handling App State Transitions Communication Between Apps Follows Specific Pathways -> Inter-App Communication Performance Tuning is Important for Apps -> Performance Tips How to Use This Document

How to Use This Document

发布到商店前看的 新学iOS看 Start Developing iOS Apps (Swift). 学习iOS看 iOS Technology Overview

yanx730 commented 7 years ago

Expected App Behaviors

在设计初需要考虑的app行为

Providing the Required Resources

必须要有的资源:

The App Bundle

Xcode将工程打包成bundle,通常包含:

Supporting User Privacy

yanx730 commented 7 years ago

The App Life Cycle

The Structure of an App

0dc685ea-b834-44b3-b045-a9b104414630

The Main Run Loop

7499ce01-ba27-4857-9ed5-4edf8e1ee05b

Execution States for Apps

0893d4c2-882f-4253-8730-e829c299af02

yanx730 commented 7 years ago

Background Execution

Executing Finite-Length Tasks

beginBackgroundTaskWithName:expirationHandler: beginBackgroundTaskWithExpirationHandler:

 - (void)applicationDidEnterBackground:(UIApplication *)application
{
    bgTask = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{
        // Clean up any unfinished task business by marking where you
        // stopped or ending the task outright.
        [application endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }];

    // Start the long-running task and return immediately.
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        // Do the work associated with the task, preferably in chunks.

        [application endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    });
}

Downloading Content in the Background

创建配置对象支持后台下载

  1. 使用NSURLSessionConfiguration 的backgroundSessionConfigurationWithIdentifier:方法创建配置对象。
  2. 设置配置对象的 sessionSendsLaunchEvents属性值为YES。
  3. 如果你的app在前台下载时,推荐也设置这个属性值为YES。
  4. 配置任何其他配置对象的属性相反。
  5. 使用配置对象创建NSURLSession对象。

Implementing Long-Running Tasks

后台长时间运行必须声明权限,iOS指定了可以在后台运行的app类型:

yanx730 commented 7 years ago

Strategies for Handling App State Transitions

What to Do at Launch Time

The Launch Cycle

Launching an app into the foreground

b10c68cf-8100-4780-82b8-3d7d089cbdb3

Launching an app into the background

0d34397a-3cbf-4a36-b12e-bb9d6fcc7601

Launching in Landscape Mode

想要默认启动就是横屏:

  1. Info.plist添加UIInterfaceOrientation,设置为UIInterfaceOrientationLandscapeLeft 或 UIInterfaceOrientationLandscapeRight
  2. 横屏布局你的View,确保autosize设置是正确的
  3. 重载ViewController的shouldAutorotateToInterfaceOrientation: 方法,左右横屏返回yes,竖屏返回No

What to Do When Your App Is Interrupted Temporarily

被打断时,在applicationWillResignActive: 方法中:

a1b623b6-f569-4766-ab7a-2d143c3a548c

What to Do When Your App Enters the Background

在applicationDidEnterBackground: 时,做如下事情:

yanx730 commented 7 years ago

Strategies for Implementing Specific App Features

下面介绍了几个类型的特性如何实现

Privacy Strategies

保护用户的数据(id、个人信息)

Protecting Data Using On-Disk Encryption

大部分iOS都是支持数据保护的,需要如下:

Identifying Unique Users of Your App

列了3个需要识别用户的场景:

Respecting Restrictions

评价的数据:

Supporting Multiple Versions of iOS

你可以使用的几个类型检查:

Preserving Your App’s Visual Appearance Across Launches

要再看!!! Tips for Developing a VoIP App