一.打电话
1.跳转到打电话的界面,打完电话不可以调回原应用
NSURL *url = [NSURL URLWithString:@"tel://10010"]
[[UIApplication sharedApplication] openURL:url];
2. 拨号之前会弹框询问用户是否拨号,拨完后能自动回到原应用,私有API,上线可能会被拒绝
NSURL *url = [NSURL URLWithString:@"telprompt://10010"];
[[UIApplication sharedApplication] openURL:url];
3.创建一个UIWebView来加载URL,拨完后能自动回到原应用. (这个webView千万不要添加到界面上来,不然会挡住其他界面)
if (_webView == nil){
_webView = [[UIWebView alloc] initWithFrame:CGRectZero];
}
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel://10010"]]];
二. 发短信
1.直接跳到发短信界面,不能指定短信内容,不能自动回到原应用
NSURL *url = [NSURL URLWithString:@"sms://10010"];
[[UIApplication sharedApplication] openURL:url];
2.使用MessageUI框架(系统的),可以指定短信内容,
参考:http://blog.sina.com.cn/s/blog_85c1f6a50100zadl.html
#import <MessageUI/MessageUI.h>
//显示发短信的控制器
MFMessageComposeViewController *vc =[[MFMessageComposeViewController alloc] init];
// 设置短信内容
vc.body = @"吃饭了没?";
// 设置收件人列表
vc.recipients = @[@"10086", @"13838383838"];
// 设置代理
vc.messageComposeDelegate = self;
// 显示控制器
[self presentViewController:vc animated:YES completion:nil];
代理方法,当短信界面关闭的时候调用,发完后会自动回到原应用-
(void)messageComposeViewController:
(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
// 关闭短信界面
[controller dismissViewControllerAnimated:YES completion:nil];
if (result == MessageComposeResultCancelled) {
NSLog(@"取消发送");
} else if (result == MessageComposeResultSent) {
NSLog(@"已经发出");
} else {
NSLog(@"发送失败"); }
}
三.发邮件
1.用自带的邮件客户端,发完邮件后不会自动回到原应用 参考:http://lizaochengwen.iteye.com/blog/1236360
NSMutableString *mailUrl = [[NSMutableString alloc]init]; //添加收件人
NSArray *toRecipients = [NSArray arrayWithObject: @"邮箱"];
[mailUrl appendFormat:@"mailto:%@", [toRecipients componentsJoinedByString:@","]]; //添加抄送 SArray *ccRecipients = [NSArray arrayWithObjects:@"邮箱", @"邮箱", nil]; [mailUrl appendFormat:@"?cc=%@", [ccRecipients componentsJoinedByString:@","]]; //添加密送 NSArray *bccRecipients = [NSArray arrayWithObjects:@"邮箱", nil]; [mailUrl appendFormat:@"&bcc=%@", [bccRecipients componentsJoinedByString:@","]]; //添加主题 [mailUrl appendString:@"&subject= 主题"]; //添加邮件内容 [mailUrl appendString:[NSString stringWithFormat:@"&body=%@",@"邮件内容"]]; // 进行ut-8编码
NSCharacterSet *set = [NSCharacterSet URLQueryAllowedCharacterSet];
NSURL *urll = [NSURL URLWithString:[mailUrl stringByAddingPercentEncodingWithAllowedCharacters:set]]; [[UIApplication sharedApplication] openURL:urll]; 或者
NSURL *url = [NSURL URLWithString:@"sms://10010"];
[[UIApplication sharedApplication] openURL:url];
2.类似短信的MFMailComposeViewController,详细使用参考
http://blog.sina.com.cn/s/blog_737cc59201016w9w.html
四.调用系统的Safari打开一些链接
NSURL *url = [NSURL URLWithString:@”http://www.baidu.com"];
[[UIApplication sharedApplication] openURL:url];
五.跳到系统设置页面
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
六.跳转到wife设置页面
NSURL*url=[NSURLURLWithString:@"prefs:root=WIFI"];[[UIApplicationsharedApplication]openURL:url];
跳转到对应的页面, 参考 http://blog.csdn.net/showhilllee/article/details/44057403
About —prefs:root=General&path=About Accessibility —prefs:root=General&path=ACCESSIBILITY Airplane Mode On —prefs:root=AIRPLANE_MODE Auto-Lock —prefs:root=General&path=AUTOLOCK Brightness —prefs:root=Brightness Bluetooth —prefs:root=General&path=Bluetooth Date & Time —prefs:root=General&path=DATE_AND_TIME FaceTime —prefs:root=FACETIME General —prefs:root=General Keyboard —prefs:root=General&path=Keyboard iCloud —prefs:root=CASTLE iCloud Storage & Backup —prefs:root=CASTLE&path=STORAGE_AND_BACKUP International —prefs:root=General&path=INTERNATIONAL Location Services —prefs:root=LOCATION_SERVICES Music —prefs:root=MUSIC Music Equalizer —prefs:root=MUSIC&path=EQ Music Volume Limit —prefs:root=MUSIC&path=VolumeLimit Network —prefs:root=General&path=Network Nike + iPod —prefs:root=NIKE_PLUS_IPOD Notes —prefs:root=NOTES Notification —prefs:root=NOTIFICATIONS_ID Phone —prefs:root=Phone Photos —prefs:root=Photos Profile —prefs:root=General&path=ManagedConfigurationList Reset —prefs:root=General&path=Reset Safari —prefs:root=Safari Siri —prefs:root=General&path=Assistant Sounds —prefs:root=Sounds Software Update —prefs:root=General&path=SOFTWARE_UPDATE_LINK Store —prefs:root=STORE Twitter —prefs:root=TWITTER Usage —prefs:root=General&path=USAGE VPN —prefs:root=General&path=Network/VPN Wallpaper —prefs:root=Wallpaper Wi-Fi —prefs:root=WIFI Setting —prefs:root=INTERNET_TETHERING
七.获取系统的infor.plist文件
1. 作用
Localiztion native development region --- CFBundleDevelopmentRegion 本地化相关,如果用户所在地没有相应的语言资源,则用这个key的value来作为默认.
Bundle display name --- CFBundleDisplayName 设置程序安装后显示的名称。应用程序名称限制在10-12个字符,如果超出,将被显示缩写名称。
Executaule file -- CFBundleExecutable 程序安装包的名称
Icon file --- CFBundleIconFile 应用程序图标名称,一般为icon.png
Bundle identifier --- CFBundleIdentifier 该束的唯一标识字符串,该字符串的格式类似com.yourcompany.yourapp,如果使用模拟器跑你的应用,这个字段没有用处,如果你需要把你的应用部署到设备上,你必须生成一个证书,而在生成证书的时候,在apple的网站上需要增加相应的app IDs.这里有一个字段Bundle identifier,如果这个Bundle identifier是一个完整字符串,那么文件中的这个字段必须和后者完全相同,如果app IDs中的字段含有通配符*,那么文件中的字符串必须符合后者的描述。
InfoDictionary version --- CFBundleInfoDictionaryVersion Info.plist格式的版本信息 Bundle OS Type code -- CFBundlePackageType:用来标识束类型的四个字母长的代码,(网上找的,不解??) Bundle versions string, short --- CFBundleShortVersionString 面向用户市场的束的版本字符串,(网上找的,不解??) Bundle creator OS Type code --- CFBundleSignature:用来标识创建者的四个字母长的代码,(网上找的,不解??) Bundle version --- CFBundleVersion 应用程序版本号,每次部署应用程序的一个新版本时,将会增加这个编号,在app store上用的。
Application require iPhone environment -- LSRequiresIPhoneOS:用于指示程序包是否只能运行在iPhone OS 系统上。Xcode自动加入这个键,并将它的值设置为true。您不应该改变这个键的值。 Main nib file base name -- NSMainNibFile 这是一个字符串,指定应用程序主nib文件的名称。如果您希望使用其它的nib文件(而不是Xcode为工程创建的缺省文件)作为主nib文件,可以将该nib文件名关联到这个键上。nib文件名不应该包含.nib扩展名。这个字段可以删除,你可以参考我前面的文章,main函数研究。 supported interface orientations -- UISupportedInterfaceOrientations 程序默认支持的方向。
2. 如何在程序中获取
NSDictionary *bundleDic = [[NSBundle mainBundle] infoDictionary];
NSString *version = [bundleDic objectForKey:@"相对应的KEY"];
八.去评论
NSString *url = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",在iTunes Connnect中查找到的APPID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url];