1.在第一个程序里打开第二个程序
二个程序里添加 URL type选项,继续点加号有 URL Schemes(URL 方案?),数组类型的,给一个 字符串作为第一个程序打开的标识符, 另外有一个URL idenifier,不知道干嘛,标准为 com.app2.test 类似的.
第一个程序添加 LSApplicationQueriesSchemes 字段,数组类型,添加第二个程序的URL Schemes
打开代码:
NSURL * url = [NSURL URLWithString:@"app2://"];
if ([[UIApplication sharedApplication]canOpenURL:url]) {
NSLog(@"can open");
[[UIApplication sharedApplication]openURL:url];
}
else{
NSLog(@"can not");
}
我们设置的URL Scheme为 app2 ,stirng类型就写做 app2://.
2.label添加html字符串,也可以将html字符串的某些格式用正则表达式表示出来方便单独的挑选.
NSString * htmlStr = @"<p><span style = 'FONT-SIZE:40px/'>class</span></p>";
NSAttributedString * attributeStr = [[NSAttributedString alloc]initWithData:[htmlStr dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
label.attributedText = attributeStr;
3.双引号代替单引号
NSString * str = @"\"hello\"";
NSString * str2 = [str stringByReplacingOccurrencesOfString:@"\"" withString:@"\'"];
NSLog(@"%@",str2);
4.可以创建类别方法,调用方法来更像系统的方法
5.用alertController表示以前的Actionsheet
alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"从相册中选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[self presentViewController:alert animated:YES completion:nil];
6.
NSDictionary * paramDic = @{
@"userId":codeStr,
@"tokenCode":tokenCodeStr
};
这样更方便些吧.