苹果10怎么分屏两个应用?

苹果10怎么分屏两个应用?,第1张

第一步、开启苹果8进入桌面,点击【设置】,

第二步、进入手机设置菜单,点击【辅助功能】,

第三步、进入辅助功能菜单,点击【触控】,

第四步、触控设置菜单中,点击开启【便捷访问】功能,

第五步、开启便捷访问,轻点2次【Home】键,手机分屏,

第六步、点击黑色区域的箭头,即可恢复手机屏幕

第一个iOS程序

首先打开Xcode—Create a new Xcode project—Single View Application--输入项目名称,同时选择使用Objective-C语言,设备选择iPhone--接下来系统默认生成一个IOS项目模板。项目目录结构如下:

firstios

此时什么也不用做,直接运行看一下(注意这里已经切换模拟器为iPhone5),没错我们看到了一个iOS应用程序:

firstIOS-iPhone5

程序的运行过程

在几乎所有的程序开发中程序一般都是从main函数开始运行的,那么IOS程序也不例外,在上图中我们可以看到Xcode为我们生成了一个main.m文件:

//

// main.m

// FirstIOS

//

// Created by Kenshin Cui on 14-2-23.

// Copyright (c) 2014年 Kenshin Cui. All rights reserved.

//

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[]) {

@autoreleasepool {

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]))

}

}

这个默认的iOS程序就是从main函数开始执行的,但是在main函数中我们其实只能看到一个方法,这个方法内部是一个消息循环(相当于一个死循环),因此运行到这个方法UIApplicationMain之后程序不会自动退出,而只有当用户手动关闭程序这个循环才结束。这个方法有四个参数

第一个参数和第二个参数其实就是main函数的参数,分别代表:参数个数、参数内容;

第三个参数代表UIApplication类(或子类)字符串,这个参数默认为nil则代表默认为UIApplication类,用户可以自定义一个类继承于这个类;如果为nil则等价于NSStringFromClass([UIApplication class]),大家可以自己试验,效果完全一样;UIApplication是单例模式,一个应用程序只有一个UIApplication对象或子对象;

第四个参数是UIApplication的代理类字符串,默认生成的是AppDelegate类,这个类主要用于监听整个应用程序生命周期的各个事件(其实类似于之前我们文章中提到的事件监听代理),当UIApplication运行过程中引发了某个事件之后会调用代理中对应的方法;

小技巧:

其实在Xcode中如果要看一些系统方法的解释或者参数说明,可以直接鼠标放到这个方法上,在Xcode右侧面板中就会给出帮助提示,如下图当我们放到UIApplicationMain上之后:

quickHelp

也就是说当执行UIApplicationMain方法后这个方法会根据第三个参数创建对应的UIApplication对象,这个对象会根据第四个参数AppDelegate创建并指定此对象为UIApplication的代理;同时UIApplication会开启一个消息循环不断监听应用程序的各个活动,当应用程序生命周期发生改变UIApplication就会调用代理对应的方法。

既然应用程序UIApplication是通过代理和外部交互的,那么我们就有必要清楚AppDelegate的 *** 作细节,下面是UIApplication详细的代码:

AppDelegate.h

//

// AppDelegate.h

//

//

// Created by Kenshin Cui on 14-2-23.

// Copyright (c) 2014年 Kenshin Cui. All rights reserved.

//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window

@end

AppDelegate.m

//

// AppDelegate.m

//

//

// Created by Kenshin Cui on 14-2-23.

// Copyright (c) 2014年 Kenshin Cui. All rights reserved.

//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

return YES

}

- (void)applicationWillResignActive:(UIApplication *)application

{

// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}

- (void)applicationDidEnterBackground:(UIApplication *)application

{

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

- (void)applicationWillEnterForeground:(UIApplication *)application

{

// Called as part of the transition from the background to the inactive statehere you can undo many of the changes made on entering the background.

}

- (void)applicationDidBecomeActive:(UIApplication *)application

{

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}

- (void)applicationWillTerminate:(UIApplication *)application

{

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

@end

这个类中定义了应用程序生命周期中各个事件的执行方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions程序启动之后执行,只有在第一次程序启动后才执行,以后不再执行;

- (void)applicationWillResignActive:(UIApplication *)application程序将要被激活时(获得焦点)执行,程序激活用户才能 *** 作;

- (void)applicationDidEnterBackground:(UIApplication *)application程序进入后台后执行,注意进入后台时会先失去焦点再进入后台;

- (void)applicationWillEnterForeground:(UIApplication *)application程序将要进入前台时执行;

- (void)applicationDidBecomeActive:(UIApplication *)application程序被激活(获得焦点)后执行,注意程序被激活时会先进入前台再被激活;

- (void)applicationWillTerminate:(UIApplication *)application程序在终止时执行,包括正常终止或异常终止,例如说一个应用程序在后太运行(例如音乐播放软件、社交软件等)占用太多内存这时会意外终止调用此方法;

为了演示程序的生命周期,不妨在每个事件中都输出一段内容,简单调整上面的代码:

AppDelegate.m

//

// AppDelegate.m

// FirstIOS

//

// Created by Kenshin Cui on 14-2-23.

// Copyright (c) 2014年 Kenshin Cui. All rights reserved.

//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

苹果智能手机完全可以同时运行多个程序。

用户在正常使用中,可以点击home键,然后当前软件就会转入后台运行,然后用户即可运行其他软件。

如果想要切换运行中的软件,用户可以双击home然后在后台中点击要切换的应用即可。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/11171287.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存