1. iPhone不进入锁屏待机状态:
[UIApplication sharedApplication].idleTimerDisabled = YES;
如果希望能进入待机锁屏状态,设置为NO就可以了。
2.设置icon上的数字图标:
[UIApplication sharedApplication].applicationIconBadgeNumber = 4;
在iOS8.0以后在使用这个属性之前必须先设置
[[UIApplication sharedApplication] registerUserNotificationSettings:];
3.设置摇动手势的时候,是否支持redo,undo操作
[UIApplication sharedApplication].applicationSupportsShakeToEdit = YES;
4.判断程序运行状态
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
}
typedef NS_ENUM(NSInteger, UIApplicationState) {
UIApplicationStateActive,
UIApplicationStateInactive,
UIApplicationStateBackground
} NS_ENUM_AVAILABLE_IOS(4_0);
5.显示联网状态
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
6.打开一个网页:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];
7.发送电子邮件
NSString *recipients =@"mailto:[email protected][email protected],[email protected]&subject=Hello from California!";
NSString *body =@"&body=It is raining in sunny California!";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:email]];
8.拨打电话:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://1234567890"]];
9.发送短信:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://1234567890"]];