ios
Cocoanerd
Pick a schedule you can live with, and stick to it. I don’t care if you suck at writing, if nobody reads, if you have nothing interesting to say. If you can demonstrate a willingness to write, and a desire to keep continually improving your writing, you will eventually be successful.
展开
-
NSURLErrorDomain Code=-1200
具体错误如下:Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.从网上看 就是在info.plist里边添加 App Transport Security Settings的Allow Arbitrary Loads为YES 就可以解决问题然而还是不行然后 在网络请求代理里边添加绕过证书方法如下://绕过证书(voi原创 2022-03-10 17:04:32 · 6064 阅读 · 0 评论 -
iOS弹窗顺序弹出管理
希望弹窗顺序弹出,但是又关心弹出的优先级。下面是自己简单的实现,不足之处,请指出。.h/** ⚠️⚠️⚠️:PRPopupManager 此管理类不关心弹窗的show和hide 只约束弹窗是否被拦截一个一个展示、或者某几个同时展示 */#import <Foundation/Foundation.h>///优先级枚举typedef NS_ENUM(NSUInteger, PRPopupPriority) { PRPopupPriorityLow = 1, //原创 2021-02-23 11:04:45 · 1554 阅读 · 1 评论 -
阿里百川 WKWebView 无法拦截URL
今天升级阿里百川SDK,据前同事说升级后,由UIWebView 替换为WKWebView后,无法再回调中拦截URL 处理其他逻辑。但是12月底前要剔除干净,刚好这阵子不忙,就升级吧。升级期间,按照[阿里百川官方文档],表示一路顺风。运行一下,果然拦截不到URL。这到底是为什么呢?看了下SDK,废话不多说,看下面这个图片,看这句话,是不是逻辑上有点含糊,先设置好代理,先调用本接口。差别就在这句话里。一开始我再webView的懒加载方法里设置的navigationDeleagete,细心的同学会看到阿里原创 2020-09-28 19:37:12 · 512 阅读 · 0 评论 -
cocoapods 1.8.0版本之后,CDN: trunk 推荐解决方法
Cocoapods 从1.8版本开始CocoaPods将默认源切换到了CDN服务,也就是不再将整个的repo master先下载下来才能正常使用pods而是用按需下载。因此:pod install 和 pod update 速度都很快一、删除原来的master索引,使用最新的trunk下的索引。查看远程源列表: pod repo listmasterType: git (master)URL: https://github.com/CocoaPods/Specs.gitPath: /User原创 2020-06-24 18:18:44 · 2060 阅读 · 0 评论 -
静态库与动态库介绍
这篇文章主要介绍静态库和动态库的区别、支持的平台架构、架构的拆分与合并,以及APP Store上架时可能遇到的问题。一、存在形式静态库:.a 和 .framework动态库:.dylib 和 .framework二、使用区别静态库:链接时,静态库会被完整的复制到可执行文件中,被多次使用就有多分冗余拷贝动态库:链接时,不复制,程序运行时由系统加载到内存,供程序调用,系统只加载一次,多个程序共用,节省内存。三、iOS的架构模拟器:CPU架构 机型 i386 i原创 2020-06-24 15:59:52 · 398 阅读 · 0 评论 -
iOS 脚本打包,无需创建多个ExportOptional.plist文件存放在工程目录
废话不多说,我想把下面这三个文件,变成一个文件。今天想整理下脚本打包,因为一直都是手动生成不同的ExportOptions.plist文件,如果(development、ad-hoc、app-store、enterprise)这四个环境都只是因为method名称或者其他参数比如bitcode有区分而要本地生成四个相对应的plist文件,岂不是感觉很笨重哦。脚本内容:#!/bin/sh# 使用方法:# step1: 将该脚本放在工程的根目录下(跟.xcworkspace文件or .xcodep原创 2020-06-11 18:08:23 · 1543 阅读 · 0 评论 -
iOS 使用iconfont
今天我们项目开始使用iconfont,至于为什么,看看下面就晓得喽介绍:Iconfont 是一套字体图标,和我们使用自定义字体的方式是一样的,并且它是一种矢量图标。计算机中显示的图形一般分为两类—位图和矢量图,我们平常使用的JPEG、PNG等图片都是位图格式,是一种由像素来表示的图像。而⚠️矢量图⚠️是由点、直线、多边形等基于数学方程的几何图元表示的图像,对比位图,矢量图具有体积小,放大缩...原创 2020-04-21 21:22:09 · 897 阅读 · 0 评论 -
clang diagnostic的简单介绍
今天项目引入了iconfont,然后看的网上的帖子,发现有部分消除警告的代码。对此还不太熟悉。于是查了下。简单罗列几种,对有强迫症的很友好使用格式:#pragma clang diagnostic push#pragma clang diagnostic ignored "-相关命令" //需要操作的代码#pragma clang diagnostic pop常见的种类://...原创 2020-04-21 20:54:04 · 749 阅读 · 0 评论 -
LaunchScreen有缓存 终极方案
遵循苹果要求,再四月底将LaunchImage改为LaunchScreen。为什么我的手机上图标那么大了呢。天知道我卸载重装了有4次可能系统会缓存启动图像,即使删除了该应用程序,它实际上也很难清除原来的缓存。应用程序的沙盒中->Library->SplashBoard的文件夹,该文件夹是启动屏缓存的存储位置。因此,要完全清除应用程序的启动屏幕缓存,您所需要做的就是在应用程序内部...原创 2020-04-02 14:43:27 · 2962 阅读 · 0 评论 -
iOS打ipa包的类型区别
develop:调试证书,包含调试信息 安装时需要证书已加入设备UDID或是越狱设备才能安装。distribution:正式证书,发布到appstore所用,屏蔽了调试信息,要想测试安装时需要证书已加入设备UDID或是越狱设备才能安装。ad-hoc:测试证书,非越狱机且没有添加入测试设备中,又想测试app,就要通过artive->adhoc,编译打包app,将app.ipa拖入itu...原创 2020-03-09 20:07:49 · 2212 阅读 · 0 评论 -
iOS oc 手机摇一摇震动带音效功能
导入#import <QuartzCore/QuartzCore.h>#import <AudioToolbox/AudioToolbox.h>核心代码- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubty...原创 2020-03-03 15:19:13 · 899 阅读 · 0 评论 -
Xcode11添加引导页(升级后Launch Images Source选项不见了)
转载添加引导页流程网上很多,大家可以自己查找,这里要说的是今天升级Xcode11后添加引导页,遇到工程 targets 里面的 App Icons and Launch Images 里面 没有了 Launch Images Source选项。(导致选择不了添加的启动页)最后在工程 targets–Build Settings 搜索 Asset Catalog Launch Image Set...转载 2019-12-18 09:37:16 · 3215 阅读 · 0 评论 -
ReactiveCocoa之RACCommand
RACCommand:RAC中用于处理事件的类,可以把事件如何处理,事件中的数据如何传递,包装到这个类中,他可以很方便的监控事件的执行过程。使用场景:按钮点击、网络请求使用步骤:1.创建命令 initWithSignalBlock:(RACSignal * (^)(id input))signalBlock2.在signalBlock中,创建RACSignal,并且作为signalBloc...原创 2019-06-04 16:27:21 · 192 阅读 · 0 评论 -
HTTP与HTTPS的区别
超文本传输协议HTTP协议被用于在Web浏览器和网站服务器之间传递信息,HTTP协议以明文方式发送内容,不提供任何方式的数据加密,如果攻击者截取了Web浏览器和网站服务器之间的传输报文,就可以直接读懂其中的信息,因此,HTTP协议不适合传输一些敏感信息,比如:信用卡号、密码等支付信息。 为了解决HTTP协议的这一缺陷,需要使用另一种协议:安全套接字层超文本传输协议HTTPS,为了数据传输的安全,...原创 2018-03-13 16:38:52 · 270 阅读 · 0 评论 -
iOS---runtime
今天看了一篇帖子,感觉挺好的。所以转载下来看看 什么是runtime? 我们写的代码在程序运行过程中都会被转化成runtime的C代码执行,例如[target doSomething];会被转化成objc_msgSend(target, @selector(doSomething));。 OC中一切都被设计成了对象,我们都知道一个类被初始化成一个实例,这个实例是一个对象。实际上一个类本质上也...转载 2018-03-14 10:30:10 · 195 阅读 · 0 评论 -
MVVM初步心得
最近公司招了一个高级开发,采用的流行的MVVM+RAC+cocopods私有库开发。一开始我一直使用的事MVC的经典模式,也没接触过组件化,在这里先简单说说采用MVVM模式开发的想法。MVC:Model View Controller (Massive View controller重量级视图控制器)从上面可以看到原来MVC模式下Controller的占比,想要未视图控制器瘦身,并且进一步分...原创 2019-04-22 16:45:39 · 311 阅读 · 0 评论 -
iOS MVVM
MVVM分别指什么Model-数据层 ViewController/View-展示层 ViewModel- 数据模型MVVM与MVC的不同首先我们简化一下MVC的架构模式图: 在这里,Controller需要做太多得事情,表示逻辑、业务逻辑,所以代码量非常的大。而MVVM: 比如我们有一个需求:一个页面,需要判断用户是否手动设置了用户名。如果设置了,正常显示用户名;如果...转载 2018-06-11 14:10:21 · 320 阅读 · 0 评论 -
iOS实现渐变颜色的三种方法
一、CAGradientLayer实现渐变 CAGradientLayer是CALayer的一个特殊子类,用于生成颜色渐变的图层,使用较为方便 下面介绍下它的相关属性: colors 渐变的颜色 locations 渐变颜色的分割点 startPoint&endPoint 颜色渐变的方向,范围在(0,0)与(1.0,1.0)之间,如(0,0)(...转载 2018-04-23 16:09:48 · 5302 阅读 · 0 评论 -
删除本地仓库
cd 到目录rm -fr .git原创 2018-10-16 18:09:53 · 454 阅读 · 0 评论 -
os升级至10.13.6以后cocopods不管用了 bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
今天升级了os系统,想用cocoapods导入第三方的时候,后来莫名其妙ruby环境出了问题只能重装但是几个ruby源都不太适用了比如:https://rubygems.org/http://ruby.taobao.org/https://ruby.taobao.org/……设置时都会出问题报错 bad response Not Found 404 (https://gems.ru...原创 2018-10-19 10:15:01 · 1411 阅读 · 0 评论 -
友盟微信分享与微信支付有冲突
今天男朋友让帮忙解决一个问题,要接入aliyunoss。但是只要cocopods一导入,就会警报提示微信支付方面的冲突。如下图按照网上的说法,将cocopods导入的友盟微信模块删掉,讲libSocialWeChat.a复制粘贴到集成的支付模块里面。然而还是没有解决根本问题。我也曾一度用去掉友盟微信分享,这样可以解决问题,但问题是微信分享被去掉了与需求不符啊。。。。 也试过将手动集成的微信支...原创 2018-10-19 09:58:51 · 2628 阅读 · 0 评论 -
iOS关于APNS推送问题小结
问题:测试环境下可以正常接收到推送通知,正式环境下却不可以接收到推送通知。并且,appstore上面的app也是可以正常接收到通知。一可能是正式推送证书过期了?让服务器那边看了,没问题。而且,appstore上面的app可以正常使用,也说明了正式推送证书没有过期。但是,问题出现在哪里???后来看到一篇文章,里面有这句话:[ ]如果你手机中的App是通过XCode直接安装的话,那么你的A...原创 2018-09-20 17:02:44 · 550 阅读 · 0 评论 -
ios端自行检查版本更新
..h文件#import "AppDelegate.h"@interface AppDelegate (VersionUpdate)- (void)checkNewVersionUpdate;@end.m文件#import "AppDelegate+VersionUpdate.h"@implementation AppDelegate (VersionUpdate)- (...原创 2018-09-20 16:58:11 · 402 阅读 · 0 评论 -
ios 根据友盟日志定位代码
话不多说直接上图: 错误信息就是上面那个图片喽。查找dYSM文件:dYSM是打包的时候生成的,查找位置可以用下面的方法,找到它就可以拿友盟统计上的错误日志来查找崩溃在程序的哪个类哪行代码了。不过,这不是绝对的,有的日志是查不到崩溃在何处的。 Xocde–&gt;preference –&gt; 在友盟统计上,错误日志这里会有应用的版本号,我们要根据这个版本号,找到我们...原创 2018-07-02 14:09:47 · 675 阅读 · 0 评论 -
NSString到底是用copy还是用strong
本质上来讲,copy和strong都没有错,但是对于追求性能的一个码农来讲他会再适当的地方用适当的修饰符那么,什么时候用copy,什么时候用strong呢?首先,为什么要用copy?因为copy安全!copy修饰的NSString,在初始化时,如果来源是NSMutableString的话,会对来源进行一次深拷贝,将来源的内存地址复制一份,这样,两个对象就一点关系就没有了,无论你怎么...原创 2018-06-21 11:22:03 · 439 阅读 · 0 评论 -
UISlider解决两边空隙
UISlider两边有空隙的解决方法 创建继承UISlider的文件,重写UISlider的这个方法注!!!不是类别文件- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value{ rect.origin.x = rect.origin.x - 10 ; ...原创 2018-05-16 18:01:22 · 1054 阅读 · 0 评论 -
WKWebview获取内容高度
//页面加载完成之后调用- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { WS(weakSelf); [webView evaluateJavaScript:@"document.body.offsetHeight;" completionHandler:^(...原创 2018-05-16 10:58:00 · 2195 阅读 · 0 评论 -
简单实现UISlider每100固定值滑动
1.在初始化UISlider的懒加载里面设置如下:_numbers = [[NSMutableArray alloc] init]; for (int i = 0; i <= (5000-2000)/100; i++) { [_numbers addObject:@(i * 100)]; } // These n...原创 2018-05-08 10:33:24 · 2758 阅读 · 0 评论 -
Instruments-time profile性能优化检测
使用Instruments中的time profile工具分析项目中的代码执行时间,找出导致程序运行慢的原因,即耗时的操作代码。打开Instruments(注意:需要先打开要检测的项目文件,然后Xcode的菜单栏中选择打开Instruments)方法1: 方法2: 选择time profile工具,并打开 运行查看(注意:选项配置)(1)Separate by Thr...转载 2018-05-11 16:46:33 · 433 阅读 · 0 评论 -
验证码倒计时 不随页面释放而停止
今天我们的Android说你做的验证码发送是倒计时60S,那界面回退上级页面后还在倒计时吗。我说没有,他说那这样等于倒计时作用不大。其实并不是作用不大,而是正常的合理逻辑就是应该界面消失,倒计时还在继续,当用户在倒计时未走完时再次进入页面,还在继续倒计时。我一开始做的最简单的,就是倒计时随着视图的消失而被释放从而停止。下面就是最简单的 声明@property (nonatomic,stron...原创 2018-04-19 11:00:50 · 1164 阅读 · 0 评论 -
Xcode10-archives面板没有export按钮
据说很强的Xcode10正式版本推送更新了,今天要测试,所以想Archive,打包出一个ipa,然后放到蒲公英上。当Archive完成,弹出Organizer的时候,发现是这样的:WTF?只有Validate App,Distribute App,没有了export选项。看字面意思,以为Distribute App就是上传到App Store,其实不然,点击Distribute App之后可以...原创 2018-10-20 14:52:53 · 4078 阅读 · 5 评论 -
iOS倒计时毫秒、时间差
- (void)timerStop { if (_timer) { [_timer invalidate]; _timer = nil; }}- (void)timerStart { if (!_timer &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; _remainTime &amp;amp;amp;amp;gt; 0) { _timer =原创 2018-11-06 14:03:26 · 1255 阅读 · 0 评论 -
iOS11后发现上拉刷新后,一直在不停的刷新并请求服务器
iOS11后发现上拉刷新后,一直在不停的刷新并请求服务器原因:iOS11中UITableView在reloadData时contentOffset发生了改变,这时候MJ监听了contentOffset的变化,就导致再一次的调用上拉加载,变成了循环调用 self.mainTableView.estimatedRowHeight = 0; self.mainTableView.estimate...原创 2018-11-05 17:00:17 · 973 阅读 · 0 评论 -
iOS开发-- 字符串分割(多个字符分割一个字符串)、拼接
NSString * ptr = @”I am a man”; //将字符串整体作为分割条件 返回值为NSArray不可变数组 NSArray * array = [ptr componentsSeparatedByString:@” “];//若修改,则将NSArray转化为NSMutableArray NSMutableArray * array1 = [NSMutableArray a转载 2017-07-03 16:15:35 · 4036 阅读 · 0 评论 -
iOS数据模拟 Mock方案
在团队比较紧密配合的情况下,接口文档先行,移动端开发玩接口,自行mock数据,联调查看效果。我这里查阅了一些资料,整理了三种方式。一、charles1.本地文件模拟数据不灵活、规模小、没有随机性、很难测试出边界情况2.远程服务模拟数据需要占用服务器资源,消耗一些测试接口的开发资源Tools–>Map Local–>Enable Map Local —>add —&g...原创 2019-08-02 14:17:28 · 1547 阅读 · 0 评论 -
ios 图片简单360度旋转动画
只需要创建一个imgview,然后赋予图片和坐标 粘贴下面的代码就好啦。。。 旋转动画开启- (void)rotateView:(UIImageView *)view{ CABasicAnimation *rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"tran...原创 2018-07-04 10:35:44 · 4199 阅读 · 0 评论 -
iOS中的内省方法
概念:内省(Introspection)是面向对象语言和环境的一个强大特性,Objective-C和Cocoa在这个方面尤其的丰富。内省是对象揭示自己作为一个运行时对象的详细信息的一种能力。这些详细信息包括对象在继承树上的位置,对象是否遵循特定的协议,以及是否可以响应特定的消息。NSObject协议和类定义了很多内省方法,用于查询运行时信息,以便根据对象的特征进行识别。好处:明智地使用内省可...原创 2019-06-13 18:15:29 · 1012 阅读 · 0 评论 -
iOS组件化中xib转nib
有的小姐姐小哥哥比较喜欢用xib,或者当我们的业务状态非常多的时候,可以利用xib+UIStackView来迅速开发,都知道大量的xib会非常的耗性能,但是偶尔一两个也是可以的。我是一个偏向于代码布局的,灵活性高,易于维护,虽然有时候一些初始化代码及布局代码可能会达到三百多行,但是还是喜欢用代码来布局。如果我们用组件化开发的话,再组件化中怎么将xib文件转为nib。奉上简便的脚本文件,来解放你...原创 2019-06-05 18:24:06 · 1283 阅读 · 0 评论 -
ViewControlle及View生命周期
写了那么多篇博客,但是感觉还是要写一些最基本的东西。就跟学会了高数,还要返回来看些基础的理论一样。1.alloc:创建对象,分配空间2.initWithCoder:(NSCoder *)aDecoder(如果使用storyboard或者xib)3.init (initWithNibName):如果通过xib初始化对象4.awakeFromNib:这个方法用的时候,outlet还没有连...原创 2019-10-08 10:41:01 · 156 阅读 · 0 评论 -
cocoapods创建私有库
今天学习cocoapods开发私有库,在师父的指导下,反反复复了好多次才自己成功完成,自己总结一下,希望对大家有所帮助。主要分为两大部分:一、私有库索引仓库 二、Pod项目工程文件一、私有库索引仓库1.创建Spec Repo先来说第一步,什么是 Spec Repo ?他是所有的Pods的一个索引,就是一个容器,所有公开的Pods都在这个里面,他实际是一个Git仓库 remote端 在Git...原创 2019-02-14 13:04:34 · 422 阅读 · 0 评论