梵讯笔记

1.iOS9新特性:Bitcode

当运行之前的项目报错时,我们可以在”Build Settings”->”Enable Bitcode”中设置属性为NO

2.获取设备名字

[Device machineName]

3.获取沙盒Documents路径

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

 NSString *documentsDirectory = [paths objectAtIndex:0];

4.发短信方法

4.1openURL

[[UIApplication sharedApplication] openURL:@"sms:12345678"];

4.2MFMessageComposeViewController

首先在程序中导入MessageUI.framework。import头文件:#import "DeviceDetection.h"

然后在代码中使用下面的语句来调用短信发送窗口,并指定号码和短信内容:

MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
 controller.title = @"短信房源";
controller.body = HouseInfo;
controller.recipients = nil;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];

5.复制内容到剪切板

UIPasteboard *pasteboard =  [UIPasteboard generalPasteboard];
pasteboard.string = ResponseObj;

6。iOS字符创中去除特殊字符串

NSInteger leftLength=[[leftStr stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length;

7.NSCharacterSet 简单用法

NSMutableCharacterSet *base = [NSMutableCharacterSet lowercaseLetterCharacterSet]; //字母
NSCharacterSet *decimalDigit = [NSCharacterSet decimalDigitCharacterSet];   //十进制数字
 [base formUnionWithCharacterSet:decimalDigit];    //字母加十进制
NSString *string = @"[email protected]#@sfn$5`SF$$%x^(#e{]e";
//用上面的base隔开string然后组成一个数组,然后通过componentsJoinedByString,来连接成一个字符串
  NSLog(@"%@",[[string componentsSeparatedByCharactersInSet:base] componentsJoinedByString:@"-"]);
  [base invert];  //非 字母加十进制
  NSLog(@"%@",[[string componentsSeparatedByCharactersInSet:base] componentsJoinedByString:@"-"]);
答应结果:

 [email protected]-s#@sfn$-`SF$$%x^(#e{]e

----5-------5--------------

8.从系统选择多张图片

先导入库ELCImagePicker(第三方)

//从照片库
        if ([self shouldImage])
        {
            ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker];
            elcPicker.maximumImagesCount = 16-[images_ numberOfPhotos];
            elcPicker.returnsOriginalImage = NO;
            elcPicker.imagePickerDelegate = self;
            [self presentViewController:elcPicker animated:YES completion:nil];
        }else
        {
            UIAlertView *al=[[UIAlertView alloc]initWithTitle:@"权限受限" message:@"设置-手机梵讯-隐私" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [al show];
        }

#pragma mark ELCImagePickerController delegate
-(void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
{
    NSString *imagePathDir;
    BOOL isSuccess = NO;
    for (NSDictionary *dict in info)
    {
        UIImage* img = [dict objectForKey:UIImagePickerControllerOriginalImage];

        imagePathDir = [[Util getHouseDirCurrentDateType] stringByReplacingOccurrencesOfString:@"_city_" withString:[YlwSingleMode shareDataModle].CityPinyin];
        //需要准备的数据
        NSString *PKHouseImageLite = [Util GetUUIDLite];
        NSString *PKHouseImage = [Util convertGuidSqlserverFromSqlite:PKHouseImageLite isClean:YES];
        NSString *imgType = @".jpg";

        CGSize sizeImageBig = [self getImageSize:img.size targetSize:CGSizeMake(600, 450)];
        CGSize sizeImageSmall = [self getImageSize:img.size targetSize:CGSizeMake(200, 150)];
        CGSize sizeImageIndex = [self getImageSize:img.size targetSize:CGSizeMake(80, 60)];

        UIImage *imgBig = [self reSizeImage:img toSize:sizeImageBig];
        UIImage *imgSmall = [self reSizeImage:img toSize:sizeImageSmall];
        UIImage *imgIndex = [self reSizeImage:img toSize:sizeImageIndex];

        imagePathDir=[imagePathDir stringByReplacingOccurrencesOfString:@"house/" withString:@"House/"];

        NSString *imagePathBig = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_big.jpg",PKHouseImage]];
        NSString *imagePathSmall = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_small.jpg",PKHouseImage]];
        NSString *imagePathIndex = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_index.jpg",PKHouseImage]];

        NSData *imgBigData = UIImageJPEGRepresentation(imgBig, 0.3);
        NSData *imgSmallData = UIImageJPEGRepresentation(imgSmall, 0.3);
        NSData *imgIndexData = UIImageJPEGRepresentation(imgIndex, 0.3);

        NSInteger imgSize_Big = imgBigData.length;
        NSInteger imgSize_Small = imgSmallData.length;

        for (int i=0; i<3; i++) {
            [_houseImageCache storeImage:imgBig imageData:imgBigData forKey:imagePathBig toDisk:YES];
            i++;
            [_houseImageCache storeImage:imgSmall imageData:imgSmallData forKey:imagePathSmall toDisk:YES];
            i++;
            [_houseImageCache storeImage:imgIndex imageData:imgIndexData forKey:imagePathIndex toDisk:YES];

        }
      isSuccess = [self saveHouseImagesWith:PKHouseImageLite ImgPath:imagePathDir ImgType:imgType ImgSizeBig:imgSize_Big ImgSizeSmaill:imgSize_Small];
        [self houseimageNumber:nil];
    }
    if (isSuccess)
    {
        [ProgressHUD showSuccess:@"添加成功"];
        [picker dismissViewControllerAnimated:YES completion:nil];
        [self reloadSubviews];
    }
}

-(void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
     NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
     NSString *imagePathDir;
    BOOL isSuccess = NO;
    if ([mediaType isEqualToString:(NSString*)kUTTypeImage])
    {
        UIImage* img = [info objectForKey:UIImagePickerControllerOriginalImage];
        UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
        imagePathDir = [[Util getHouseDirCurrentDateType] stringByReplacingOccurrencesOfString:@"_city_" withString:[YlwSingleMode shareDataModle].CityPinyin];
        //需要准备的数据
        NSString *PKHouseImageLite = [Util GetUUIDLite];
        NSString *PKHouseImage = [Util convertGuidSqlserverFromSqlite:PKHouseImageLite isClean:YES];
        NSString *imgType = @".jpg";

        CGSize sizeImageBig = [self getImageSize:img.size targetSize:CGSizeMake(600, 450)];
        CGSize sizeImageSmall = [self getImageSize:img.size targetSize:CGSizeMake(200, 150)];
        CGSize sizeImageIndex = [self getImageSize:img.size targetSize:CGSizeMake(80, 60)];

        UIImage *imgBig = [self reSizeImage:img toSize:sizeImageBig];
        UIImage *imgSmall = [self reSizeImage:img toSize:sizeImageSmall];
        UIImage *imgIndex = [self reSizeImage:img toSize:sizeImageIndex];

        imagePathDir=[imagePathDir stringByReplacingOccurrencesOfString:@"house/" withString:@"House/"];

        NSString *imagePathBig = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_big.jpg",PKHouseImage]];
        NSString *imagePathSmall = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_small.jpg",PKHouseImage]];
        NSString *imagePathIndex = [imagePathDir stringByAppendingPathComponent:[NSString stringWithFormat:@"house_%@_index.jpg",PKHouseImage]];

        NSData *imgBigData = UIImageJPEGRepresentation(imgBig, 0.3);
        NSData *imgSmallData = UIImageJPEGRepresentation(imgSmall, 0.3);
        NSData *imgIndexData = UIImageJPEGRepresentation(imgIndex, 0.3);

        NSInteger imgSize_Big = imgBigData.length;
        NSInteger imgSize_Small = imgSmallData.length;

        for (int i=0; i<3; i++) {
            [_houseImageCache storeImage:imgBig imageData:imgBigData forKey:imagePathBig toDisk:YES];
            i++;
            [_houseImageCache storeImage:imgSmall imageData:imgSmallData forKey:imagePathSmall toDisk:YES];
            i++;
            [_houseImageCache storeImage:imgIndex imageData:imgIndexData forKey:imagePathIndex toDisk:YES];

        }
        isSuccess = [self saveHouseImagesWith:PKHouseImageLite ImgPath:imagePathDir ImgType:imgType ImgSizeBig:imgSize_Big ImgSizeSmaill:imgSize_Small];
        [self houseimageNumber:nil];
        if (isSuccess)
        {
            [ProgressHUD showSuccess:@"添加成功"];
            [picker dismissViewControllerAnimated:YES completion:nil];
            [self reloadSubviews];
        }
    }
}

-(void)image:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo{

    if (!error)
    {
        NSLog(@"保存有误");
    }
    else
    {
        NSLog(@"错误提示%@", error);
    }
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

9.判断是否支持拍照和相册

-(BOOL)shouldPhoto
{
    BOOL agree=NO;
    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if(authStatus == AVAuthorizationStatusAuthorized||authStatus == AVAuthorizationStatusNotDetermined)
    {
        agree=YES;
    }else
    {
        agree=NO;
    }
    return agree;
}
-(BOOL)shouldImage
{
    BOOL agree=NO;
    ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
    if(author == ALAuthorizationStatusAuthorized||author == ALAuthorizationStatusNotDetermined)
    {
        agree=YES;
    }else
    {
        agree=NO;
    }
    return agree;
}

10.上传图片

+(void)httpUploadHeadImage:(NSString *)Actio WithParam:(NSDictionary *)param success:(void(^)(id ResponseObject))Success Failure:(void (^)(id ResponseObject))Failure
{
    NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
    if (param!=nil)
    {
        [mDict setDictionary:param];
    }
    AFHTTPRequestOperationManager * manager =[AFHTTPRequestOperationManager manager];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:Actio parameters:NULL constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
    {
        [formData appendPartWithFormData:[[NSString stringWithString:[mDict objectForKey:@"PKUser"]] dataUsingEncoding:NSUTF8StringEncoding] name:@"PKUser"];
        [formData appendPartWithFormData:[[NSString stringWithString:[mDict objectForKey:@"relPath"]] dataUsingEncoding:NSUTF8StringEncoding] name:@"relPath"];
        NSData * data=[NSData dataWithContentsOfFile:[mDict objectForKey:@"HeadBig"]];
        [formData appendPartWithFileData:data name:@"big" fileName:[mDict objectForKey:@"HadebigName"] mimeType: @"Image/jpep"];
        NSData * data1=[NSData dataWithContentsOfFile:[mDict objectForKey:@"Headsmall"]];

        [formData appendPartWithFileData:data1 name:@"small" fileName:[mDict objectForKey:@"HadesmallName"] mimeType: @"Image/png"];

    } success:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        NSData * responseData = responseObject;
        NSString * responseStr =  [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
        Success(responseStr);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {

    }];
}

时间: 2024-10-14 00:45:12

梵讯笔记的相关文章

ios 读取通讯录

1.获取通讯录列表 +(NSMutableDictionary*)getAddressPeopleArray { BOOL granted = [AddressEngine getAccessGranted]; // NSMutableArray*addArray=[NSMutableArray arrayWithCapacity:0]; NSMutableDictionary * addrDic = [NSMutableDictionary dictionaryWithCapacity:0];

腾讯地图笔记

首先是js的引用 <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=YOUR_KEY"></script> 腾讯地图js除了提供基本的功能库外,还提供了一些有用的附加库,下面这个是引用了坐标转换库的js引用 <script type="text/javascript" charset="utf-8" src=

展讯sc7731 LCD驱动简明笔记之三

此篇笔记基于sc7731 - android 5.1,对lcd的gralloc库做一个简明笔记. 第一部分 调用gralloc.sc8830.so所谓的Gralloc模块,它就是一个模块,一个操作kernel层framebuffer驱动的动态库模块,它属于大名鼎鼎的HAL层.用的时候就加载到内存空间,不用的时候就从内存空间中卸载掉.下面看下系统如何将该模块加载到内存空间的.在Android系统中,所有访问HAL层模块的应用,都需要通过一个叫 hw_get_module() 的方法去获得需要的HA

展讯sc7731 LCD驱动简明笔记之二

此篇笔记基于sc7731 - android 5.1,对lcd的framebuffer做一个简明笔记. 一共分为两大部分:第一部分,关于LCD的硬件方面的:第二部分,关于lcd核心处理(framebuffer)部分的. 第一部分,LCD硬件相关的 一.液晶 液晶是一种高分子有机材料.当给它加上直流电场后,原本有序的分子排列被打乱,一部分液晶变得不透明,颜色加深,便因此显示出字符和图形. 液晶的光电效应:干涉.散射.衍射.旋光.吸收等. 二.LCD种类 1. 构造: 使用两块玻璃板夹着一块液晶:一

读书笔记:腾讯传_中国互联网公司进化论

2017年的时候立了一个旗帜,2017年读30本书,其中包括5本外文原版书.现在4月份了,终于完成第二本<腾讯传>.. 主席说,读完一本书,写一写读书笔记会印象更深刻.嗯,实践是对某种认知的最好认识.那就立刻行动起来:) 这本书其实主要是花费两个通宵看完的,快毕业了,睡不着又不想起来写论文(其实应该起来写论文的啊摔!),就在床上看这本书,其实很好看(=看成功的记录写实总是很容易的),根据微信读书记录,前后共花了5个+小时..这5个+小时就是实大实在屏幕前阅读的时间,这样,我读完了这本书,有挺多

学习笔记:腾讯云--域名解析

一周多的等待终于域名备案完成,开始域名解析.发现好多坑,亏的有个好老师,不然跳进去了我得好几天出不来. 开始域名解析: 1解析域名:腾讯云在域名管理里要点两次解析,第二次才是真正的开始. 注:此处的添加域名,可以添加其他域名 2.添加记录 2.1记录类型这里鼠标滑过的时候有详细的解释.这里我们选A. 2.2主机记录:这里填写主域名和二级域名 这里我犯了一个让我找了好久的错误,我第一遍填写的是www.xiaocigua.cn 结果访问不到服务器. 这里的主机记录直接填写域名前缀就可以.如:直接解析

读书笔记 --腾讯传

我们很早的时候就用过腾讯的产品,可是我们对腾讯的了解并不多,<腾讯传>这本书的作者是吴晓波,他深入到腾讯内部,并且通过近千人次的员工访谈,才完成了这本书. 这本书讲述了腾讯的成长经历,腾讯的发展也是中国互联网企业发展的缩影. 作者在书中提出了许多问题,并且作出了解答: 首先腾讯的创始人马化腾是一个怎样的人? 马化腾爱好天文.机房病毒制造者.中国最早的bbs网站站长.寻呼机系统. 其中不得不提到腾讯五虎:马化腾(大Boss).张志东(技术).许晨晔(公关).陈一丹(法律.行政).曾李青(市场),

读书笔记 - 《腾讯方法》

作为一本打完折之后要近30元的书来说,只有一百四十页的内容,实在是性价比太差了.不过我犹豫了很久,还是买了下来,毕竟还是要以需求急迫度为第一考虑要素.这本书讲了三个小故事,天美艺游工作室的创立.摩登城市的起死回生.QQ秀从卖道具向包月转型.第一个参考价值最大,也是我最想知道的,看完略有收获,树立统一的目标.引入人才.调整组织结构.建立绩效评价.调整薪酬体系.每日构建并试玩.关注产品细节,这些都是很实用的东西也确实被用上了.里面有个细节很有意思,张志东要求团队向微信团队学习,11周全团队都加班到凌

【学习笔记】&quot;ListView滑动删除 ,仿腾讯QQ&quot;(二)

今天继续学习"鸿祥_"大神的写的"ListView滑动删除,仿腾讯QQ" . 1.关于dispatchTouchEvent 之前,只用过onTouchEvent,现在才知道一个Touch事件居然如此复杂.OK,集中精力,且看下文(本段内容主要参考Android dispatchTouchEvent介绍): 一个最简单的屏幕触摸动作触发了一系列Touch事件:ACTION_DOWN->ACTION_MOVE->ACTION_MOVE->ACTION_