随笔分类 -  iOS

摘要:-(NSString *)testA{ int a = ?; if (a>5) { return @"a大于5"; } else if(a<5) { return @"a不大于5"; } return @"default"; } 当? =1 ,返回"a不大于5" 当? =10 ,返回"a大于5" 当 阅读全文
posted @ 2017-10-11 17:45 liuw_flexi 阅读(903) 评论(0) 推荐(0)
摘要:1. 在模型文件的Entity里面增加字段名 2. Xcode工具栏选择Edtor->Creat NSManagerObject SubClass->...->生成新的关联文件 3. 删除原来的旧关联文件 阅读全文
posted @ 2017-09-25 13:28 liuw_flexi 阅读(404) 评论(0) 推荐(0)
摘要:用线程代表不同售票窗口,用线程执行的方法模拟售票。如果不加锁,会出现多个售票窗口同时售一张票的情况。 @property (nonatomic, strong) NSThread *thread1; @property (nonatomic, strong) NSThread *thread2; @ 阅读全文
posted @ 2017-09-17 15:23 liuw_flexi 阅读(392) 评论(0) 推荐(0)
摘要:当有文字输入时,UITextView上的默认文字消失,没有任何输入时,显示默认文字。 做法: 1. 在自定义UITextView的初始化方法- (id)initWithFrame:(CGRect)frame里面注册通知,监听文本变化: 2. 调setNeedsDisplay 触发drawRect 方 阅读全文
posted @ 2017-09-17 15:03 liuw_flexi 阅读(311) 评论(0) 推荐(0)
摘要:滚动时导航栏透明度变化,然后滚动到一定距离,导航栏完全出现。 这里是做法的主要思路: 1. 整个页面是一个tableView, 然后个人信息部分是一个背景图片,作为tableView的headView。因为UITableView继承自UIScrollView,滚动处理在这个方法里处理 2. 可以设置 阅读全文
posted @ 2017-09-17 14:26 liuw_flexi 阅读(1209) 评论(0) 推荐(0)
摘要:// colum/列/字段// row/行/记录// 主键的作用是唯一标识一条记录// sql语句注意:不区分大小写,以分号结束(不要分号也行?) // 如果增加字段,可能要指定数据类型,SQL中的五种数据类型:字符型,文本型,数值型,逻辑型和日期型。 http://www.cnblogs.com/ 阅读全文
posted @ 2017-09-15 16:48 liuw_flexi 阅读(174) 评论(0) 推荐(0)
摘要:CABasicAnimation *anim = [CABasicAnimation animation]; anim.keyPath = @"transform.scale"; anim.toValue = @0.5; anim.repeatCount = MAXFLOAT; [_heartIma 阅读全文
posted @ 2017-09-15 12:18 liuw_flexi 阅读(410) 评论(0) 推荐(0)
摘要:command + 左右 = 横竖屏旋转 command + H + H = 切入层级后台模式 阅读全文
posted @ 2017-09-14 19:42 liuw_flexi 阅读(156) 评论(0) 推荐(0)
摘要:storyboard中2个按钮,一个点击,一个移动动画用的 阅读全文
posted @ 2017-09-14 19:34 liuw_flexi 阅读(329) 评论(0) 推荐(0)
摘要:1. 面试上海某家软件公司,题目是这样,有一个View,距左右父View长度一定,高度一定。这个View上面有4个小View,高度相同(或者说一定), 要求不管屏幕怎么变,这4个小View总是等宽平分大View。 用AutoLayout来做确实很快,而且公司期望就是让你这样做。所以,一个字,就是干: 阅读全文
posted @ 2017-09-14 19:31 liuw_flexi 阅读(534) 评论(0) 推荐(0)
摘要:1. 播放mp3需要导入框架,AVFoundation支持音频文件(.caf、.aif、.wav、.wmv和.mp3)的播放。 步骤: a.声明一个音频播放对象: b.用一个支持的文件路径来初始化_player: (据说只能播放本地文件,像酷我等音乐软件应该是播放前下载到本地,然后进行播放的,因为在 阅读全文
posted @ 2017-09-11 19:18 liuw_flexi 阅读(603) 评论(0) 推荐(0)
摘要:1. 如果系统自带的布局的话,是这样: 而自定义的话:WaterFlowLayout : UICollectionViewLayout 系统UICollectionViewFlowLayout也是继承自UICollectionViewLayout 2. 主要实现部分:在- (void)prepare 阅读全文
posted @ 2017-09-08 16:05 liuw_flexi 阅读(396) 评论(0) 推荐(0)
摘要:1. UISearchBar 是UIKit提供的最简单,底层的一个控件,创建它: 他有一个代理UISearchBarDelegate,代理方法里常用的是这个: - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar; 2. UISe 阅读全文
posted @ 2017-09-07 16:46 liuw_flexi 阅读(502) 评论(0) 推荐(0)
摘要:WebViewJavascriptBridge 1.load加载 ,去本地查找html路径方式 2.[NSURL fileURLWithPath:htmlPath] 和 [NSURL URLWithString:htmlPath]的区别 3.有人说WKWebView加载本地html,9.0以前不能用 阅读全文
posted @ 2017-05-24 12:04 liuw_flexi 阅读(394) 评论(0) 推荐(0)
摘要:之前一直纠结在使用UIWebView上,发现加载6个UIWebView占用了290M左右内存,切换时还会增加。后来看到一篇文章:http://blog.csdn.net/kongu/article/details/46878623 试了一下WKWebVIew,发现一直在29M左右,29M啊,29M! 阅读全文
posted @ 2017-05-01 21:49 liuw_flexi 阅读(404) 评论(0) 推荐(0)
摘要:Xcode出现报错,"Xcode build:clang: error: linker command failed with exit code 1 (use -v to..." 但是没有给出详细信息,可以看这里: 这里会显示详细错误信息 有一次面试被问到:程序闪退,崩溃,如何知道哪里报错? 其实 阅读全文
posted @ 2017-04-22 20:16 liuw_flexi 阅读(4648) 评论(0) 推荐(0)
摘要:还在用老版本的ccoaPods,安装三方库时,会报错 : 1、查看ruby源 gem sources -l 2、移除掉原有的源 gem sources --remove https://rubygems.org/ 3、添加国内最新的源。ruby-china gem sources -a https: 阅读全文
posted @ 2017-04-22 19:56 liuw_flexi 阅读(4501) 评论(0) 推荐(0)
摘要:基于项目报错: WebViewJavascriptBridgeBase 中定义:@property (assign) id <WebViewJavascriptBridgeBaseDelegate> delegate; 但是dealloc中没有释放 - (void)dealloc { self.st 阅读全文
posted @ 2017-04-21 11:14 liuw_flexi 阅读(329) 评论(0) 推荐(0)
摘要:一. 有一次面试问到:从VC1 推到VC2会不会调用dealloc呢?答案是不会 而从VC2 dismiss 会调VC2的dealloc 不会调用VC1的dealloc方法 有代码为证: #import "ViewController.h" #import "ViewController2.h" @ 阅读全文
posted @ 2017-04-21 10:57 liuw_flexi 阅读(271) 评论(0) 推荐(0)