iOS开发-------初识

发布于 2019-12-25 15:28:57

pragram预处理指令

pragram mark

代码逻辑分块

常用快捷键
查看文档说明
选中要查看的api,按住option+左键:

注释
cmd + /

框架
Masonry
autolayout
http://adad184.com/2014/09/28/use-masonry-to-quick-solve-autolayout/
### 使用注意

  • 案例

make.left.equalTo(self.contentView).offset(12);
make.top.equalTo(self.contentView).offset(18);
make.size.width.mas_equalTo(32);
make.size.height.mas_equalTo(32);
每个属性设置都单独写;因为是链式语法,如果所有属性的配置都放在一起感觉后面的设置会覆盖前面的设置。

  • 居中

make.center

  • 垂直居中

    make.centerY
  • 水平居中

    meke.centerX

工具
cocoapods
程序依赖管理
http://blog.devtang.com/2014/05/25/use-cocoapod-to-manage-ios-lib-dependency/

Sketch
http://xclient.info/s/sketch.html?_=f4b9875cb3f64933e7149aa2d7a5060e

Git

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001373962845513aefd77a99f4145f0a2c7a7ca057e7570000

SourceTree
https://www.sourcetreeapp.com

控件
UIImageView
http://blog.sina.com.cn/s/blog_9c2363ad0101e15l.html

圆形ImageView
imageView.layer.cornerRadius = imageView.frame.size.with/2; //设置半径为宽度的一半
imageView.layer.masksToBounds = YES; //隐藏掉被遮挡的内容;
UITableView
https://www.kancloud.cn/digest/ios-1/107419

设置UITableViewDelegate,试图加载委托
设置UITableViewDataSource,数据绑定
可以自定义Cell,需要继承UITableViewCell
坑:
Q:使用Section实现“历史消息”,将TableView的Style设置Group,分别重写HeightForFooter,heightForHeader,ViewForHeader后,section之间出现了一个分割;
A:重写ViewForFooter后,将改方法的返回值设为nil,分割就取消了;
scrollView每次滑动后会回调layoutSubViews方法
UITextView
类似于Android里面的EditText

UILabel
文本

富文本
https://www.jianshu.com/p/5d24d22f99c3

UIButton
UIAlertController
UIView
将父View的高度设置为0后,但是子view的高度仍然不变且正常显示,此时要对父view进行裁剪使得子View消失。即要设置父 view的clipsToBounds = YES;

API
UIFont
设置文本字体

UITableViewDelegate
UITableViewDataSource
异常
编译失败,符号冲突
由于import了.m文件,导致;import .h文件后编译成功;

unrecognized selector sent to instance
给nil对象发送了消息

自定义的UITableViewCell没有被UI TableView调用
需要调用UITableView的registerClass方法注册自定义的cell

NSInternalInconsistencyException
reason: 'couldn't find a common superview for <UITextView: 0x7fdb4d015200;
原因:是在设置view的约束前没有调用addSubView方法将view添加到parent view中。
解决办法:是在view初始化完成后调用parentview的addsubview方法;

TODO
js在微信、微博、QQ、Safari唤起App的解决方案
https://segmentfault.com/a/1190000012940046

0 条评论

发布
问题

官网
微信

官方微信