您的位置:首页 > 其它

判断设备的类型ipad或者iphone,调用自带应用,禁止锁屏,设置icon上的数字

2013-03-08 10:51 405 查看
1. 判断设备的类型ipad或者iphone,可在main中定义一个宏来记录。

#define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] &&[[UIDevice currentDevice] userInterfaceIdion] == UIUserInterfaceIdiomPad)

//开始登录或者注册
- (void)loginOrRegisterUser:(UIViewController *)aViewController;
{
if ([[UIDevicecurrentDevice]
userInterfaceIdiom ] ==UIUserInterfaceIdiomPhone ) {

UserLoginViewController *vc = [[UserLoginViewControlleralloc]
init];

vc.modalTransitionStyle =UIModalTransitionStyleCoverVertical;
[self.deckControllerpresentModalViewController:vc
animated:YES];
[vc release];
}
else {

UserLoginViewController_iPad *vc = [[UserLoginViewController_iPadalloc]
initWithNibName:@"UserLoginView_iPad"bundle:nil];

vc.modalTransitionStyle =UIModalTransitionStyleCoverVertical;
[aViewController presentModalViewController:vcanimated:YES];
[vc release];
}
}

2. 调用自带应用

调用Email

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://email邮箱地址"]];

调用系统电话phone

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://88888888"]];

调用SMS

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://888588"]];

调用自带浏览器Safari

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://网址"]];

还有:itms:// 可以打开MobileStore.app

audio-player-event:// 可以打开iPod

audio-player-event://?uicmd=show-purchased-playlist 可以打开iPod播放列表

video-player-event:// 可以打开iPod中的视频

3. 禁止锁屏

UIApplication *app = [UIApplication sharedApplication];

app.idleTimerDisabled = YES;

4. 设置icon上的数字

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: