每个app有且只有一个UIApplication对象,当程序启动的时候通过调用UIApplicationMain方法得到的。可以通过sharedApplication方法得到。

UIApplication对象的主要任务是处理用户事件的处理路径,例如分发一个UIEvent到另外一个对象去处理。UIApplication对象持有众多的UIWindow对象,因此可以组织app的展示。UIApplication对象还能处理一些资源,例如通过openURL:打开邮箱客户端或者设置界面等。

获得UIApplication对象

[UIApplication sharedApplication]

获得UIApplicationDelegate对象

[[UIApplication sharedApplication] delegate]

获得UIWindow对象

[[UIApplication sharedApplication] windows];   //UIWindow数组
[[UIApplication sharedApplication] keyWindow]; //UIWindow数组中最后调用makeKeyAndVisible方法的UIWindow对象

控制和处理UIEvent

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{//分发一个event到另外一个对象去处理
[[UIApplication sharedApplication] sendAction:@selector(action: forEvent:) to:[CustomHandler sharedCustomHandler] from:self forEvent:event];
}
[[UIApplication sharedApplication] beginIgnoringInteractionEvents]; //开始忽略Event
//...中间调用动画等操作
[[UIApplication sharedApplication] endIgnoringInteractionEvents]; //结束忽略Event
[UIApplication sharedApplication].applicationSupportsShakeToEdit = YES;  //晃动是否有撤销或者重做动作

打开URL资源

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];//打开设置界面

配置通知设置

UIUserNotificationType  types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings]; //注册远程推送通知
[[UIApplication sharedApplication] registerForRemoteNotifications];//注册
[[UIApplication sharedApplication] unregisterForRemoteNotifications];//注销
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow:10];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = date; //时间
localNotif.timeZone = [NSTimeZone localTimeZone]; //时区
localNotif.repeatInterval = NSCalendarUnitMinute; //间隔
localNotif.soundName = UILocalNotificationDefaultSoundName; //声音
localNotif.alertBody = @"Local Test"; //通知内容
localNotif.applicationIconBadgeNumber = 1; //数字标示
localNotif.userInfo = @{@"key":@"test"}; //info
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; //注册通知
    [[UIApplication sharedApplication] presentLocalNotificationNow:localNotif]; //立即通知
[[UIApplication sharedApplication] cancelAllLocalNotifications]; //取消所有通知
[[UIApplication sharedApplication] cancelLocalNotification:localNotif]; //取消特定的通知 NSArray *arr = [[UIApplication sharedApplication] scheduledLocalNotifications]; //所有的通知

后台运行相关

    [[UIApplication sharedApplication] applicationState]; //app状态
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:3600]; //设置后台运行时间
NSTimeInterval remainTime = [[UIApplication sharedApplication] backgroundTimeRemaining]; //app后台运行的时间
NSLog(@"remainTIme = %f",remainTime);
int state = [[UIApplication sharedApplication] backgroundRefreshStatus]; //后台刷新的状态
NSLog(@"state = %d",state);
[[UIApplication sharedApplication] beginBackgroundTaskWithName:@"taskOne" expirationHandler:^{
}];
[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
}];
[[UIApplication sharedApplication] endBackgroundTask:1];

远程的控制相关

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];

系统的Idle Timer

[UIApplication sharedApplication].idleTimerDisabled = YES; //不让手机休眠

APP样式

    //隐藏状态条
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
//设置状态条的样式
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[[UIApplication sharedApplication] statusBarStyle];
//状态条的Frame
[[UIApplication sharedApplication] statusBarFrame];
//网络是否可见
[[UIApplication sharedApplication] isNetworkActivityIndicatorVisible];
//badge数字
[UIApplication sharedApplication].applicationIconBadgeNumber = 2;
//屏幕的方向
[[UIApplication sharedApplication] userInterfaceLayoutDirection];

设置状态条的方向

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];

数据类型

UIBackgroundTaskIdentifier : Int
typedef enum : NSUInteger {
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
} UIRemoteNotificationType;
typedef enum : NSInteger {
UIStatusBarStyleDefault,
UIStatusBarStyleLightContent, UIStatusBarStyleBlackTranslucent,
UIStatusBarStyleBlackOpaque
} UIStatusBarStyle;
typedef enum : NSInteger {
UIStatusBarAnimationNone,
UIStatusBarAnimationFade,
UIStatusBarAnimationSlide,
} UIStatusBarAnimation;
typedef enum : NSInteger  {
UIApplicationStateActive ,
UIApplicationStateInactive ,
UIApplicationStateBackground
} UIApplicationState;
const UIBackgroundTaskIdentifier  UIBackgroundTaskInvalid ;
const NSTimeInterval UIMinimumKeepAliveTimeout;
typedef enum : NSUInteger  {
UIBackgroundFetchResultNewData ,
UIBackgroundFetchResultNoData ,
UIBackgroundFetchResultFailed
} UIBackgroundFetchResult;
const NSTimeInterval  UIApplicationBackgroundFetchIntervalMinimum ;
const NSTimeInterval UIApplicationBackgroundFetchIntervalNever;
typedef enum : NSUInteger  {
UIBackgroundRefreshStatusRestricted ,
UIBackgroundRefreshStatusDenied ,
UIBackgroundRefreshStatusAvailable
} UIBackgroundRefreshStatus;
typedef enum : NSInteger  {
UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown ,
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait ,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown ,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight ,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
typedef enum : NSInteger  {
UIUserInterfaceLayoutDirectionLeftToRight ,
UIUserInterfaceLayoutDirectionRightToLeft ,
} UIUserInterfaceLayoutDirection;
NSString *const  UIApplicationOpenSettingsURLString;
NSString *const  UIApplicationStatusBarOrientationUserInfoKey ;
NSString *const UIApplicationStatusBarFrameUserInfoKey;
NSString *const  UIContentSizeCategoryExtraSmall ;
NSString *const UIContentSizeCategorySmall ;
NSString *const UIContentSizeCategoryMedium ;
NSString *const UIContentSizeCategoryLarge ;
NSString *const UIContentSizeCategoryExtraLarge ;
NSString *const UIContentSizeCategoryExtraExtraLarge ;
NSString *const UIContentSizeCategoryExtraExtraExtraLarge;
NSString *const  UIContentSizeCategoryAccessibilityMedium ;
NSString *const UIContentSizeCategoryAccessibilityLarge ;
NSString *const UIContentSizeCategoryAccessibilityExtraLarge ;
NSString *const UIContentSizeCategoryAccessibilityExtraExtraLarge ;
NSString *const UIContentSizeCategoryAccessibilityExtraExtraExtraLarge;
NSString *const  UIApplicationInvalidInterfaceOrientationException;

通知

UIApplicationBackgroundRefreshStatusDidChangeNotification
UIApplicationDidBecomeActiveNotification
UIApplicationDidChangeStatusBarFrameNotification
UIApplicationDidChangeStatusBarOrientationNotification
UIApplicationDidEnterBackgroundNotification
UIApplicationDidFinishLaunchingNotification
UIApplicationDidReceiveMemoryWarningNotification
UIApplicationProtectedDataDidBecomeAvailable
UIApplicationProtectedDataWillBecomeUnavailable
UIApplicationSignificantTimeChangeNotification
UIApplicationUserDidTakeScreenshotNotification
UIApplicationWillChangeStatusBarOrientationNotification
UIApplicationWillChangeStatusBarFrameNotification
UIApplicationWillEnterForegroundNotification
UIApplicationWillResignActiveNotification
UIApplicationWillTerminateNotification
UIContentSizeCategoryDidChangeNotification

UIApplication详解再解-备的更多相关文章

  1. S​Q​L​_​S​e​r​v​e​r​_​2​0​0​8​定​期​自​动​备​份​详​细​图​解

    S​Q​L​_​S​e​r​v​e​r​_​2​0​0​8​定​期​自​动​备​份​详​细​图​解 设置自动数据库的定期备份计划. http://wenku.baidu.com/link?url=Tu ...

  2. linux下如何打包压缩?解包解压?.tar文件.gz文件

    ===文件打包.压缩 ==打包 tar [root@521478.com]# tar -cvf etc1.tar /etc //c创建 v详细 f打包后文件名 [root@521478.com]# t ...

  3. iOS之UIApplication详解

    UIApplication对象特点: 特点1: UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序,而且是单例的.(用来封装整个应用程序的一个对象, ...

  4. 【转】iOS UIApplication详解

    1.状态栏UIStateBar的设置是在UIApplication里面设置的,它包含4中风格 2. - (void)beginIgnoringInteractionEvents; (void)endI ...

  5. UIApplication详解

    每个app有且只有一个UIApplication对象,当程序启动的时候通过调用UIApplicationMain方法得到的.可以通过sharedApplication方法得到. UIApplicati ...

  6. javascript运行机制详解: 再谈Event Loop(转)

    作者: 阮一峰 日期: 2014年10月 8日 一年前,我写了一篇<什么是 Event Loop?>,谈了我对Event Loop的理解. 上个月,我偶然看到了Philip Roberts ...

  7. Jenkins通过FTP上传站点太多文件导致太慢且不稳定,切换为压包上传再解压的思路(asp.net)

    在本地先处理好要上传的站点文件之后,可能会因为一些网页切图导致ftp上传不稳定,中断,或者文件占用的问题. 那么换了一种实现思路,要借助jenkins的工具jenkins-cli.jar. 解决思路: ...

  8. 工控安全入门(三)—— 再解S7comm

    之前的文章我们都是在ctf的基础上学习工控协议知识的,显然这样对于S7comm的认识还不够深刻,这次就做一个实战补全,看看S7comm还有哪些值得我们深挖的地方. 本篇是对S7comm的补全和实战,阅 ...

  9. Django ORM中使用update_or_create功能再解

    以前,我解过这个问题,现在百度搜索,发了像也只能找到我这个帖子. https://www.cnblogs.com/aguncn/p/4922654.html 今天,看了看官方文档,关于这个update ...

随机推荐

  1. Android中日志工具的使用

    添加LogCat到你的Eclipse日志在任何项目的开发过程中都会起到非常重要的作用,在Android项目中如果你想要查看日志则必须要使用LogCat工具.当你第一次在Eclipse中运行Androi ...

  2. VCC、VDD、VEE、VSS

    转载自:http://www.cnblogs.com/asus119/archive/2011/10/11/2206841.html 版本一: 简单说来,可以这样理解: 一.解释 VCC:C=circ ...

  3. JVM-ClassLoader(转)

    在加载阶段主要用到的是方法区: 方法区是可供各条线程共享的运行时内存区域.存储了每一个类的结构信息,例如运行时常量池(Runtime Constant Pool).字段和方法数据.构造函数和普通方法的 ...

  4. 两表关联更新,用于update 回滚

    create table test1 as select * from dba_objects; create table test2 as select * from dba_objects; cr ...

  5. Linux系统编程(33)—— socket编程之TCP程序的错误处理

    上一篇的例子不仅功能简单,而且简单到几乎没有什么错误处理,我们知道,系统调用不能保证每次都成功,必须进行出错处理,这样一方面可以保证程序逻辑正常,另一方面可以迅速得到故障信息. 为使错误处理的代码不影 ...

  6. 2014-08-04 BBS主页页面的设计

    今天是在吾索实习的第19天.这天,开始参照一开始设计的界面原型,真真正正地进行BBS界面的设计.在运用.NET进行界面设计时,发现没有用RP进行界面设计来得容易,很多都要再进行更精细的操作,才能达到原 ...

  7. 如何在Windows下使用matplotlib

    在开始之前,向matplotlib的创造者,John D. Hunter表示崇高的敬意,和无尽的怀念. (John D. Hunter 1968-2012) matplotlib是一个给予Python ...

  8. Codeforces Round #316 (Div. 2) D、E

    Problem D: 题意:给定一棵n个点树,每个点有一个字母,有m个询问,每次询问某个节点x的子树中所有深度为k的点能否组成一个回文串 分析:一堆点能组成回文串当且仅当数量为奇数的字母不多于1个,显 ...

  9. C#系列教程——lock语句定义及使用

    代码如下: using System; using System.Threading; class Thread_Test { public void Run() { Console.WriteLin ...

  10. 项目开发中封装一个BarButtonItem类别-很实用

    Encapsulates a TabBarItem--封装一个BarButtonItem类 在我们程序的导航栏的左边或右边一般都会有这样的BarButtonItem,用来界面之间的跳转 如果我们有很多 ...