包含标签 IOS 的文章

JSPatch使用

JSPatch 热更新 参考文档 jspatch语法 JSPatchConvertor 这个转换代码不能直接使用 原理 装换工具 (js对象转oc对象) // JSChange.h #import <Foundation/Foundation.h> @interface JSChange : NSObject + (instancetype)boxObj:(id)obj; @end // JSChange.m #import "JSChange.h" @interface JSChange () @property (nonatomic) id obj; @end @implementation JSChange + (instancetype)boxObj:(id)obj { JSChange *boxing = [[JSChange alloc] init]; boxing.obj = obj; return boxing; } @end //用法 JSChange.boxObj("www.Q1231321132Q.com").obj() 嵌入项目代码 1 cocoapods target 'MIOS' do platform :ios, '8.0' pod "JSPatch" end 2 js嵌入 [JPEngine startEngine]; NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"mq" ofType:@"js"]; NSString *script = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:nil]; [JPEngine evaluateScript:script]; 3 jsDemo require('UIColor,NSString,NSURLRequest,NSURL,JSChange'); defineClass('WebTest', { // viewDidLoad:……

阅读全文

tabview 性能优化

tableView性能优化 cell重用 1 定义ID 2 初始化 //tabview 初始化 - (UITableView*)TabView{ if (!_TabView) { UITableView* v = [[UITableView alloc]init]; v.delegate = self; v.dataSource = self; // 右侧指示器设置 v.sectionIndexBackgroundColor = [UIColor clearColor]; v.sectionIndexColor = PKSecondaryTextColor; v.sectionIndexMinimumDisplayRowCount = 0; // 不显示分割线 v.separatorStyle = UITableViewCellSeparatorStyleNone; [v registerClass:[PKCreateCircleAddFriendHeadCell class] forCellReuseIdentifier:@"head"]; [v registerNib:[UINib nibWithNibName:NSStringFromClass([PKCreateCircleAddFriendSeeCell class]) bundle:nil] forCellReuseIdentifier:@"body"]; _TabView = v; } return _TabView; } //cell 初始化 @implementation PKCreateCircleAddFriendHeadCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self setup]; } return self; } @end //xib cell 初始化 @implementation PKCreateCircleAddFriendSeeCell #pragma mark - Life cycle.生命周期方……

阅读全文

外部链接打开APP

外部链接打开APP 1 注册协议 /** 外部web传入路径 */ @property (nonatomic, strong) NSURL *openUrl; 2 启动设置 3 回调 // 其它应用启动本应用时,回调 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ self.openUrl = nil; BOOL result = [UMSocialSnsService handleOpenURL:url]; if (result == FALSE) { //调用其他SDK,例如支付宝SDK等 self.openUrl = url; } return result; } 4 处理 // 程序获得焦点 - (void)applicationDidBecomeActive:(UIApplication *)application { [PKTestMessage hidHUD]; // 1.发送程序启动通知 [[NSNotificationCenter defaultCenter] postNotificationName:ApplicationDidBecomeActiveNotification object:nil]; // 2.处理外部打开 if……

阅读全文

字符串emoji处理

单个字符emoji转UTF-8 //emojiTab + (NSArray*)emojiReplaceTab{ NSArray * emojiArray = @[@"😀",@"😁",@"😂",@"😃",@"😄",@"😅",@"😆",@"😈",@"😉"……

阅读全文

UITabView内部元素拖动

UITabView内部元素拖动 1加手势识别器 - (void)longPressGestureRecognized:(id)sender{ UILongPressGestureRecognizer *longPress = (UILongPressGestureRecognizer *)sender; UIGestureRecognizerState longPressState = longPress.state; //手指在tableView中的位置 _fingerLocation = [longPress locationInView:self]; //手指按住位置对应的indexPath,可能为nil _relocatedIndexPath = [self indexPathForRowAtPoint:_fingerLocation]; switch (longPressState) { case UIGestureRecognizerStateBegan:{ //手势开始,对被选中cell截图,隐藏原cell break; } case UIGestureRecognizerStateChanged:{ //点击位置移动,判断手指按住位置是否进……

阅读全文

ALAsset中fullScreenImage和fullResolutionImage使用中的区别

ALAsset fullScreenImage fullResolutionImage 选中 问题描述 1 ALAsset读图 fullScreenImage 情况正常 2 fullResolutionImage 图片反转 需要重新设置图片选转值 // fullScreenImage可以直接初始化为UIImage UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage]; // 需传入方向和缩放比例,否则方向和尺寸都不对 UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullResolutionImage scale:asset.defaultRepresentation.scale orientation:(UIImageOrientation)asset.defaultRepresentation.orientation]; //实际使用 注意内存释放 ALAsset *asset = assets[i]; ALAssetRepresentation *assetRep = [asset defaultRepresentation]; UIImage *image = [UIImage imageWithCGImage:[assetRep fullResolutionImage] scale:assetRep.scale orientation:(UIImageOrientation)assetRep.orientation]; 遍历视频文……

阅读全文

class-dump

class-dump class-dump 官网 class-dump-3.5.dmg 安装 1.将class-dump-3.5.dmg内的class-dump拉到目录: /usr/local/bin 命令 1.class-dump -H /Applications/Calculator.app -o /Users/Rio/Desktop/calculate\ heads 2.class-dump -H /Applications/Calculator.app -o /Users/ray/Desktop/ipa/calculator \head……

阅读全文

归档

代码 NSString *UserId = [NSString stringWithFormat:@"%ldAAAAAAATTTTTTTT.data", [PKUserInfoTool userInfo].uid]; NSString *PKPostLablePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:UserId]; NSMutableArray *ary = [NSMutableArray array]; for (int i = 0; i < 100; i++) { [ary addObject:[NSArray arrayWithObjects:[NSString stringWithFormat:@"label%d",i],@"123",@"456", nil]]; } PKLog(@"pring in ram%@", ary); //写入数组 [[NSFileManager defaultManager] removeItemAtPath:PKPostLablePath error:nil]; [NSKeyedArchiver archiveRootObject:ary toFile:PKPostLablePath]; //读取数组 ary = nil; PKLog(@"read from local:%@", ary); ary = [NSKeyedUnarchiver unarchiveObjectWithFile:PKPostLablePath]; PKLog(@"read from local:%@", ary); 数据内容 016-04-21 15:17:57.338 djcars[5590:140020] pring in ram[ [ label0, 123, 456 ], [ label1, 123, 456 ], [ label2, 123, 456 ], [ label3, 123, 456 ], [ label4, 123, 456 ], [ label5, 123, 456 ], [ label6, 123, 456 ], [ label7, 123, 456 ], [ label8, 123, 456 ], [ label9, 123, 456 ] ]……

阅读全文

MJExtension 模型转换

起因 来了新公司,看看上一手的代码,如果上一手,有使用过类似的工具就不会导致现在呢么多坑. 快速引用 #import "MJExtension.h" MJCodingImplementation + (NSDictionary *)replacedKeyFromPropertyName{ return @{@"hashString":@"hash"}; } + (NSDictionary *)mj_objectClassInArray{ return @{ @"newsList":[TTVHomeChannelNewsModelNewsList class], @"headlineList":[TTVHomeChannelNewsModelNewsList class], }; } MJExtension 归档 测试程序 NSString *UserId = [NSString stringWithFormat:@"%ldAAAAAAATTTTTTTT.data", [PKUserInfoTool userInfo].uid]; NSString *PKPostLablePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:UserId]; NSMutableArray *ary = [NSMutableArray array]; for (int i = 0; i < 10; i++) { [ary addObject:[NSArray arrayWithObjects:[NSString stringWithFormat:@"label%d",i],@"123",@"456", nil]]; } PKLog(@"pring in ram%@", ary); PKLabelSelectionModel *data = [[PKLabelSelectionModel alloc] init]; data.ids = ary; //写入数组 [[NSFileManager defaultManager] removeItemAtPath:PKPostLablePath error:nil]; [NSKeyedArchiver archiveRootObject:data toFile:PKPostLablePath]; //读……

阅读全文

IOS 消息推送

推送参考 IOS开发之实现App消息推送 主要流程 1.你的IOS应用需要去注册APNS消息推送功能。 2.当苹果APNS推送服收到来自你应用的注册消息就会返回一串device token给你(很重要) 3.将应用收到的device Token传给你本地的Push服务器。 4.当你需要为应用推送……

阅读全文