
iOS开发笔记
Leonardo_Fibonacci
make it happen make it better
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
02-CoreData 的增删改查
CoreData 的增删改查基本的增删改查的操作1 数据库的创建- (void)createDB{ // 1.1 创建路径 NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"AT_CoreDataDemo1" withExtension:@"momd"]; // 1.2 根据模型文件路径创建...原创 2019-01-02 10:14:34 · 282 阅读 · 0 评论 -
05-自己创建mapmodel自定义迁移方式
自动创建Mapping如果模型的改变很大或者不支持轻量级数据迁移的条件,则我们需要进行自定义迁移。使用映射模型 适用于更加复杂的数据的迁移NSMappingModel类似于数据模型NSEntityMapping告知迁移过程如何在目标数据存储中处理源实体的映射。映射类型决定了如何处理目标数据存储中的特定实体。映射类型有添加 移除 复制 变换。添加映射:一个目标中的新实体添加到目标数...原创 2019-01-09 11:14:38 · 480 阅读 · 0 评论 -
04- CoreData轻量级版本的迁移
CoreData版本的迁移一 轻量级的数据迁移例如添加新的实体,新的实体属性。轻量级版本迁移方案非常简单,大多数迁移工作都是由系统完成的,只需要告诉系统迁移方式即可。在持久化存储协调器(PSC)初始化对应的持久化存储(NSPersistentStore)对象时,设置options参数即可,参数是一个字典。PSC会根据传入的字典,自动推断版本迁移的过程。1 新建一个版本的数据库模型选中需...原创 2019-01-03 10:51:43 · 356 阅读 · 0 评论 -
03-NSPredicate谓词
NSPredicate 谓词在查询数据的过程中,给NSFetchRequest设置一个过滤条件,不需要讲所有的托管对象加载到内存中去。这样的话就会节省内存和加快查找速度。一 运算符1 比较运算符、< 、== 、>= 、<= 、!=比如说age>80NSPredicate *pre = [NSPredicate predicateWithFormat:@"a...原创 2019-01-02 10:15:19 · 265 阅读 · 0 评论 -
01-CoreData 概述
CoreData 主要的几个类1 概述CoreData 是iOS 3 之后出现的一种数据持久化方案,提供了一种ORM的存储关系,CoreData 是直接将对象存储到数据库中去,也可以将数据库中的数据转化为OC对象,过程中不用编写SQL语句。2 几个类的讲解NSManagedObjectContext 托管对象上下文 进行数据操作使用的这个类NSManagedObjectModel 托管...原创 2019-01-02 09:59:42 · 496 阅读 · 0 评论 -
Dispatch 执行ABC任务,执行完成之后刷新UI,指定任务D
在swift中分组管理异步任务的方式1 group enter 和 leave 进行同步管理 func method1() { // 创建一个组 ,要是在一个控制器中去规划请求顺序,则这个组要是全局的组 let group = DispatchGroup(); let queue = DispatchQueue.global(); ...原创 2019-06-24 12:12:23 · 851 阅读 · 0 评论 -
iOS asset 中定义颜色,xib中便捷访问
在aseet 中定义一个颜色 这样就可以在xib 中访问颜色了,这样就不用重复的去输入原创 2021-04-02 17:26:06 · 413 阅读 · 0 评论 -
iOS 解决app退出后台应用重新启动的问题
原创 2021-01-21 15:15:22 · 3812 阅读 · 0 评论 -
iOS 对数组中的字母进行排序
NSArray *array1 = @[@"G",@"B",@"R",@"S",@"A"]; NSArray *sortedArr = [array1 sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { return [obj1 compare:obj2 options:NSNumericSearch]; ..原创 2021-01-19 14:01:21 · 589 阅读 · 0 评论 -
iOS UITableview 截取长图
- (UIImage *)snapshotScreen{if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){ UIGraphicsBeginImageContextWithOptions(self.tableView.contentSize, NO, [UIScreen mainScreen].scale); } else { UIGraphicsBeginImageContext(self.tableV.原创 2021-01-12 16:03:30 · 731 阅读 · 0 评论 -
iOS 获取指定时间的前后N个月
https://www.cnblogs.com/SUPER-F/p/7298548.html正数为后 负数为前-(NSDate *)getPriousorLaterDateFromDate:(NSDate *)date withMonth:(NSInteger)month{ NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setMonth:month]; NSCalendar *ca...转载 2021-01-12 11:10:38 · 264 阅读 · 0 评论 -
iOS 没到年底NSDate 时间出错问题
NSDate *currentDate = [NSDate date];//获取当前时间,日期 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];// [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];使用小...原创 2020-12-28 10:11:19 · 206 阅读 · 0 评论 -
iOS Named colors do not work prior to iOS 11.0问题解决
原文链接https://stackoverflow.com/questions/48014246/named-colors-do-not-work-prior-to-ios-11-0-error-referring-to-a-storyboard/52967313#529673131 打开对应文件source code2 粘贴查找 使用正则表达式color key=(.*) name=.*3 用以下代码覆盖color key=$1 red="1" green="1...原创 2020-12-03 16:47:36 · 1681 阅读 · 0 评论 -
iOS 根据中文字符串排序出字母索引
// 传入字符串数组 返回索引字典- (NSDictionary *)createCharacter:(NSMutableArray *)strArr{ NSMutableDictionary *dict = [NSMutableDictionary dictionary]; for (NSString *stringdict in strArr) { NSString *string = stringdict; if ([string length])原创 2020-11-19 11:00:02 · 394 阅读 · 0 评论 -
iOS textfiled监听输入框输入中文
(void)awakeFromNib{[super awakeFromNib];self.searchFiled.delegate = self;self.searchBgView.layer.cornerRadius = 3;self.searchBgView.layer.masksToBounds = YES;[self.searchFiled addTarget:self action:@selector(textFieldEditingChanged:) forControlEven..原创 2020-11-04 16:43:36 · 295 阅读 · 0 评论 -
iOS URL的Encode 与 URLDecode
/** * URLEncode */- (NSString *)URLEncodedString:(NSString *)str{ // CharactersToBeEscaped = @":/?&=;+!@#$()~',*"; // CharactersToLeaveUnescaped = @"[]."; NSString *unencodedString = str; NSString *encodedString = (NSString *)原创 2020-08-19 12:04:41 · 1696 阅读 · 0 评论 -
iOS 关闭页面侧滑手势
-(void)popGestureChange:(UIViewController *)vc enable:(BOOL)enable{ if ([vc.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { //遍历所有的手势 for (UIGestureRecognizer *popGesture in vc.navigationCont...原创 2020-08-07 14:55:37 · 1070 阅读 · 0 评论 -
iOS 数组中的模型去重
NSMutableDictionary *mutableDic = [NSMutableDictionary dictionary]; for (HomeRectProductModel *model in self.modelArr) { [mutableDic setValue:model forKey:model.Id]; } ...原创 2020-08-05 17:03:54 · 1152 阅读 · 0 评论 -
iOS 计算两个日期之间的差值
NSDateFormatter *dateFomatter = [[NSDateFormatter alloc] init]; dateFomatter.dateFormat = @"yyyy-MM-dd HH:mm"; // 当前时间字符串格式 NSDate *planDate = [dateFomatter dateFromString:[model.PlanTime substringToIndex:16]]; // 当前日历 .原创 2020-08-04 17:30:14 · 731 阅读 · 0 评论 -
iOS 直播心形点赞动画
iOS 直播心形点赞动画https://github.com/KKKiller/KKHeartFlyAnimation原创 2020-07-06 16:18:20 · 1136 阅读 · 0 评论 -
iOS 加载本地和网络gif 图片类扩展
https://github.com/AlexanderYeah/GifKuoZhan[self.meiXueImgView showGifImageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"美" ofType:@"gif"]]];原创 2020-07-03 11:50:29 · 723 阅读 · 0 评论 -
iOS给UILabel设置内边距
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; style.alignment = NSTextAlignmentJustified; style.firstLineHeadIndent = 10.0f; style.headIndent = 10.0f; style.tailIndent = -10.0f; NSAttribu...原创 2020-06-24 11:47:30 · 3171 阅读 · 0 评论 -
iOS 修改系统的音量
#import <MediaPlayer/MediaPlayer.h> @property (strong, nonatomic) MPVolumeView *volumeView;@property (strong, nonatomic) UISlider *volumeViewSlider;- (void)viewDidLoad { if (!self.volumeView) { self.volumeView = [[MPVolumeV原创 2020-06-19 17:54:00 · 741 阅读 · 0 评论 -
iOS访问系统日历 添加提醒事件
1 添加隐私请求提示Privacy - Calendars Usage Description2 代码#import <EventKit/EventKit.h>// 添加提醒事件- (void)addEventWithTimeStr:(NSString *)timeStr title:(NSString *)title planId:(NSString *)planId{ EKEventStore *store = [[EKEventStore alloc] ini原创 2020-06-17 15:45:04 · 1791 阅读 · 0 评论 -
iOS scrollToItemAtIndexPath 无效的解决方案
在UITableview中放置的UICollectionView,然后设置滚动没有效果scrollToItemAtIndexPath- (void)layoutSubviews{ [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.selectedIdx inSection:0] atScrollPosition:UICollectionViewScrollPositionNon原创 2020-06-10 17:48:47 · 5383 阅读 · 0 评论 -
iOS 仿微信灵活添加标签
iOS 仿微信灵活添加标签原作者的github 地址 喜欢的点赞https://github.com/DreamFlyingCow/TTTags效果如下,iOS 13 访问私有属性 会崩溃,自己修改一下即可TTTagView.m 文件修改如下我的备份:https://github.com/AlexanderYeah/TTTagDemo// [_tfInput setValue:_inputPlaceHolderTextColor forKeyPath:@"_placeho原创 2020-06-09 14:42:40 · 471 阅读 · 0 评论 -
iOS 设置UILabel 的行间距
//// UILabel+LineSpace.h //#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN@interface UILabel (LineSpace)/** 设置文本,并指定行间距 @param text 文本内容 @param lineSpacing 行间距 */-(void)setText...原创 2020-05-07 10:46:33 · 748 阅读 · 0 评论 -
Cocoapods CDN: trunk Repo update failed 报错
[!] CDN: trunk Repo update failed - 2 error(s):CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/2/3/6/FDFullscreenPopGesture/1.0/FDFullscreenPopG...原创 2020-04-26 14:43:38 · 1232 阅读 · 0 评论 -
iOS 开发者账号 到期续费问题
https://blog.youkuaiyun.com/liruiqing520/article/details/104043221转载 2020-04-16 10:16:56 · 923 阅读 · 0 评论 -
Mac 升级系统 pod 命令无效
mac 升级完最新的系统之后 使用pod 命令之后无效报错-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory解决方案sudo gem install -n ...原创 2020-04-15 16:12:28 · 438 阅读 · 0 评论 -
json转换模型利器--JSONExport
JSONExport从json 到 Model ,如此的方便swift oc java 全部支持原创 2020-04-09 10:27:21 · 549 阅读 · 0 评论 -
iOS 13 如何删除SceneDelegate
Xcode11之后新创建的工程会多出两个文件SceneDelegate。那么我们如何让它变回之前的那样的工程呢。一、将这两个文件删除。会报错There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file.二、将Info....原创 2020-04-01 17:17:00 · 5686 阅读 · 0 评论 -
iOS 13 适配TextField 崩溃问题
iOS 13 之后直接通过以下方式修改Textfield的时候会出现报错信息[_accountText setValue:Color_666666 forKeyPath:@"_placeholderLabel.textColor"];报错信息Access to UITextField’s _placeholderLabel ivar is prohibited. This is an app...原创 2020-03-03 10:22:03 · 1423 阅读 · 0 评论 -
适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题
// 适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题if (@available(iOS 13.0, *)) { // [[UITabBar appearance] setUnselectedItemTintColor:Color_666666];}...原创 2020-03-02 12:03:45 · 1039 阅读 · 0 评论 -
iOS 标签自动布局
导入SKTagFrame SKTagFrame *frame = [[SKTagFrame alloc] init]; frame.tagsArray = self.bigModel.Tags; // 添加标签 CGFloat first_H = 0; CGFloat total_H = 0; for...原创 2020-01-13 11:47:18 · 1661 阅读 · 0 评论 -
iOS 验证码倒计时按钮
具体使用[SmsTimerManager sharedManager].second = (int)time;[[SmsTimerManager sharedManager] resetTime];[SmsTimerManager sharedManager].delegate = self;[strongSelf updateTime];设置代理方法 更新按钮的标题(void)u...原创 2019-12-30 09:40:21 · 231 阅读 · 1 评论 -
iOS 监听tableview 滚动距离的优雅方式
[self.tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object chan...原创 2019-12-03 16:22:14 · 3304 阅读 · 0 评论 -
iOS 在每一个cell上添加一个定时器的方案
1 首先创建一个数组,用来创建所有的定时器的时间- (NSMutableArray *)totalLastTime{ if (!_totalLastTime) { _totalLastTime = [NSMutableArray array]; } return _totalLastTime;}2 当从网络请求过来时间之后,循环遍历,行数和时间作...原创 2019-12-03 14:28:12 · 2383 阅读 · 0 评论 -
微信支付invalid total_fee 的报错
因为我的测试商品是0.01的原因是微信支付的金额是不能带小数点的直接在提交的时候 乘以 100操作 ,因为里面设置参数的时候是 以分为单位的 [packageParams setObject: price forKey:@"total_fee"]; //订单金额,单位为分...原创 2019-11-25 14:33:01 · 511 阅读 · 0 评论 -
iOS 开发之便捷宏定义
#define URL(A/*str*/) [NSURL URLWithString:A]// 图片#define IMAGE(A/*str*/) [UIImage imageNamed:A]// 快速转换字符串#define LD_STR(A/*str*/) [NSString stringWithFormat:@"%ld",A]#define F2_STR(A/*str*/) ...原创 2019-11-13 11:41:26 · 142 阅读 · 0 评论