代码杂记(功能方法 随时更新)
2015-01-29 19:03
260 查看
1. NSString *strippedString=[searchTextstringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceCharacterSet]];
去掉前后空格
An object representing a URL (Universal Resource Locator). UIKit supports many schemes, includinghttp,https,tel,facetime, andmailto
schemes.
- (BOOL)openURL:(NSURL
*)url
func openURL(_url:NSURL)
-> Bool
2.打开网址,跳转网页。
else if([@"url"isEqualToString:entityType])
{
NSMutableString* app_url = [NSMutableStringstringWithString:Onepromotion.entityId];
if(!([app_url
hasPrefix:@"http://"] || [app_url
hasPrefix:@"https://"]))
{
[app_url insertString:@"http://"atIndex:0];
}
if ([[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:app_url]])
{
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:app_url]];
}else{
NSLog(@"app_url=%@",app_url);
}
3.点击可以拨号
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"telprompt://%@",@"1008611"]]];//拨号
会出现提示框
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",@"1008611"]]]; //直接拨号,不会出现提示
4.邮件
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@",@"tao.xu@wellav.com"]]];
5.利用FaceTime进行视频通话
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"facetime://%@",@"ytdxxt10@163.com"]]];
6.延迟加载(2s)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0
* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self loadTestData];
[LDCollectView
reloadData];
[_headerView endRefreshing];
});
7.获取当前终端的语言
NSArray *array=[[NSUserDefaultsstandardUserDefaults]objectForKey:@"AppleLanguages"];
NSLog(@"%@",array[0]);
8.数组的逆序
NSArray *tempArray =
@[@1,@2,@3,@4];
tempArray = tempArray.reverseObjectEnumerator.allObjects;
去掉前后空格
An object representing a URL (Universal Resource Locator). UIKit supports many schemes, includinghttp,https,tel,facetime, andmailto
schemes.
- (BOOL)openURL:(NSURL
*)url
func openURL(_url:NSURL)
-> Bool
2.打开网址,跳转网页。
else if([@"url"isEqualToString:entityType])
{
NSMutableString* app_url = [NSMutableStringstringWithString:Onepromotion.entityId];
if(!([app_url
hasPrefix:@"http://"] || [app_url
hasPrefix:@"https://"]))
{
[app_url insertString:@"http://"atIndex:0];
}
if ([[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:app_url]])
{
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:app_url]];
}else{
NSLog(@"app_url=%@",app_url);
}
3.点击可以拨号
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"telprompt://%@",@"1008611"]]];//拨号
会出现提示框
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",@"1008611"]]]; //直接拨号,不会出现提示
4.邮件
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@",@"tao.xu@wellav.com"]]];
5.利用FaceTime进行视频通话
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"facetime://%@",@"ytdxxt10@163.com"]]];
6.延迟加载(2s)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0
* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self loadTestData];
[LDCollectView
reloadData];
[_headerView endRefreshing];
});
7.获取当前终端的语言
NSArray *array=[[NSUserDefaultsstandardUserDefaults]objectForKey:@"AppleLanguages"];
NSLog(@"%@",array[0]);
8.数组的逆序
NSArray *tempArray =
@[@1,@2,@3,@4];
tempArray = tempArray.reverseObjectEnumerator.allObjects;
相关文章推荐
- 打开新页面的几种方法(随时更新)
- 创建二维数组的方法(随时更新)
- C#代码常用功能方法;
- C# ASP.NET 最常用的通用权限的3个方法例子展示(每个功能一行代码实现)
- 【经验】花生壳试用有感及问题解决方法,随时更新。
- ASP分页代码更新 (利用微软自己提供的pagesize功能)
- Zend Studio for Eclipse代码提示功能消失的解决方法
- C# ASP.NET 最常用的通用权限的3个方法例子展示(每个功能一行代码实现)
- Android 小方法(一)--随时添加更新
- DedeCMS增强"更新系统缓存"功能的修改方法
- 事件驱动自动生成静态页面模板解决方法(二)——生成静态页面(2007年9月13日更新代码)
- N个Flex常用功能代码-【更新】
- FormValidate 表单验证功能代码更新并提供下载
- MyEclipse6.5汉化方法及代码提示功能
- 经典vim插件功能说明、安装方法和使用方法介绍(已更新)
- 用VC++获取系统时间几种方法(随时更新)
- FormValidate 表单验证功能代码更新并提供下载
- jQuery常用实例代码(随时更新)
- C# ASP.NET 最常用的通用权限的3个方法例子展示(每个功能一行代码实现)
- C# ASP.NET 最常用的通用权限的3个方法例子展示(每个功能一行代码实现)