iOS-技术细节整理
遇到未使用类,可以看看xcode->help->developer documentation
下面做一下简单的技术细节整理
Auto Layout
使用Auto Layout来灵活改变UI elements,使得各个元素可以使用不同尺寸、翻转状态的屏幕。红线表示还有未声明的约束。
术语:
leading trailing top bottom 左右上下
margin边界
建立storyboard与viewcontroller
联系建立后,viewcontroller中的代码名称不可修改,否则无法索引
添加viewcontroller控件
建立storyboard与viewcontroller之间的联系,与viewcontroller自定义类绑定;
可以在attribute inspector中设置 is initial view controller,即为app的entry point
*Button
直接添加action响应函数
*slider
直接添加action响应函数(event: value changed)
*显示提示信息
舍弃UIAlertView,需要使用UIAlertController
UIAlertController
可以设置title、message,可以添加UIAlertAction
使用viewcontroller的present显示(alert是模态视图)
func present(UIViewController, animated: Bool, completion: (() -> Void)? = nil)
Presents a view controller modally.
UIAlertAction
An action that can be taken when the user taps a button in an alert.
原本的提示框转到了界面下方的模态视图
模态视图理解为一个浮动在原先视图上的一个临时性的视图或者界面
note:模态视图
覆盖于原有view之上的临时图层
*访问相机和照片
info中添加key Privacy - Camera Usage Description
建立ui和viewcontroller的联系(outlet、action)
Outlets let you refer to your interface elements in code, but you still need a way to respond whenever the user interacts with the elements. That’s where actions come in.
event-driven programming
iOS apps are based on event-driven programming. That is, the flow of the app is determined by events: system events and user actions.
target-action pattern
target-action pattern in iOS app design. Target-action is a design pattern where one object sends a message to another object when a specific event occurs.
for example:
The event is the user tapping the Set Default Text button.
The action is setDefaultLabelText(_).
The target is ViewController (where the action method is defined).
The sender is the Set Default Label Text button.
The system sends the message by calling the action method on the target and passing in the sender object. The sender is usually a control—such as a button, slider, or switch—that can trigger an event in response to user interaction such as a tap, drag, or value change.
delegate
Any object can serve as a delegate for another object as long as it conforms to the appropriate protocol.
textfield的delegate可以实现以下响应
func textFieldDidEndEditing(_ textField: UITextField) {
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
}
first responder
When the user taps a text field, it automatically becomes the first responder. In an app, the first responder is an object that is first on the line for receiving many kinds of app events, including key events, motion events, and action messages, among others. In other words, many of the events generated by the user are initially routed to the first responder.
When a user wants to finish editing the text field, the text field needs to resign its first-responder status. Because the text field will no longer be the active object in the app, events need to get routed to a more appropriate object.
tips
使用注释//MARK:、function menu快速索引
//MARK: Properties
//MARK: Actions
Functions menu
In Xcode, a jump menu that lets you navigate directly to a specific declaration or section in a source code file.
iOS-技术细节整理的更多相关文章
- iOS资源整理
开发类库 http://www.code4app.com/thread-7831-1-1.html Github-iOS备忘 http://github.ibireme.com/github/list ...
- iOS Socket 整理以及CocoaAsyncSocket、SRWebSocket源码解析(一)
写在准备动手的时候: Socket通讯在iOS中也是很常见,自己最近也一直在学习Telegram这个开源项目,Telegram就是在Socket的基础上做的即时通讯,这个相信了解这个开源项目的也都知道 ...
- iOS开发--整理常用的第三方资源
一:第三方插件 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地址:https://github. ...
- iOS 动画整理
序列帧动画 曾经项目里的一段源码: 1234567891011121314 UIImageView * activityImageView = [[UIImageView alloc] init];N ...
- iOS适配整理
iOS12适配问题 1.StatusBar内部结构改变 现象:crash crash log: -[_UIStatusBarIdentifier isEqualToString:]: unrecogn ...
- 【iOS】iOS CocoaPods 整理
github 上下载 Demo 时第一次遇到这个情况,当时有些不知所措,也没怎么在意,后来项目调整结构时正式见到了这个,并且自己去了解学习了. CocoaPods安装和使用教程 这篇文章写得很好!ma ...
- iOS runtime整理
iOS利用Runtime自定义控制器POP手势动画 http://www.cocoachina.com/ios/20150401/11459.html Objective C运行时(runtime) ...
- iOS设计规范整理|汇总
来源 UI中国
- Mysql相关技术细节整理
一.错误日志相关 1.mysql错误日志所在位置 windows下,错误日志文件一般在安装目录下的data目录下.扩展名是.err的文件,也可以打开安装目录下的my.ini文件检查一下linux下,错 ...
- iOS错误整理--自定义按钮,给按钮内部赋值出现的错误
一.练习中为了实现自定义按钮,按钮中的imageView和titleLabel默认是左右排列的.在练习中自定义为上下排列. *在以下方法中重新布局按钮中的子控件 - (void)layoutSubvi ...
随机推荐
- normal 普通身份 sysdba 系统管理员身份 sysoper 系统操作员身份 dba和sysdba
as sysdba 就是以sysdba登录,oracle登录身份有三种:normal 普通身份sysdba 系统管理员身份sysoper 系统操作员身份每种身份对应不同的权限 sysdba权限:●启动 ...
- 使用 get post 注意事项
快速判断: 如下情况使用GET方法:客户端与服务端的交互像是一个提问(如查询操作.搜索操作.读操作) 如下情况使用POST方法: 1.交互是一个命令或订单(order),比提问包含更多信 ...
- Hibernate知识点小结汇总
Hibernate部分 1.为什么要使用Hibernate开发你的项目呢?Hibernate的开发流程是怎么样的? 为什么要使用 ①.对JDBC访问数据库的代码做了封装,大大简化了数据访问层繁琐的重复 ...
- flexible.js在华某为手机上使用rem时,页面宽度超出手机屏幕宽度
问题:手机端项目在华为的某款手机上显示时页面内容没有自适应手机宽度,出现横向滚动条 原因:手机获取手机屏幕宽度并计算出rem时出现偏差,明显宽余真实手机屏宽度 解决方案一:在页面里获取页面最外层dom ...
- 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛--I-填空题
链接:https://www.nowcoder.com/acm/contest/90/I 来源:牛客网 1.题目描述 牛客网是是一个专注于程序员的学习和成长的专业平台,集笔面试系统.课程教育.社群交流 ...
- kali下添加用户和权限分配
1.添加用户 useradd -m test #-m的意思是创建用户的主目录 2.为用户test设置密码. passwd test 3.为添加的用户赋予权限(-a 添加 :-G 群组) 如果没有这一步 ...
- Jenkins 添加节点 java web方式
环境说明: 主节点:windows server 从节点:两台linux 1. windows server安装jenkins就不多说了,直接添加节点配置如下 2.全局安全配置,指定确认的端口后,记得 ...
- html样式不兼容 详解(转)
网站对火狐不兼容的原因以及解决的方法 1.DOCTYPE 影响 CSS 处理 2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行 3. ...
- Nginx反向代理 Laravel获取真实IP地址(PHP)
使用VUE前后端分离开发 后端使用Laravel 想要获取到用户的真实IP地址 因为分离开发不同源跨域问题 所以只能进行前端Nginx反向代理 location /api { rewrite ^/a ...
- MAC和windows开发操作系统环境,解决Maven工程中报 Missing artifact jdk.tools:jdk.tools
同事使用的是苹果mac,而我们其他人的开发环境是windows jdk1.8 导致同事从git上pull下来的工程,pom文件是直接报错的, windows下的pom文件设置是这样的: <dep ...