您的位置:首页 > 编程语言

代码杂记(功能方法 随时更新)

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: