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 ...
随机推荐
- Android学习笔记_16_添加多个Activity、参数传递、请求码和结果码使用
一.添加新的Activity步骤: 第一步:新建一个继承Activity的类,如:NewActivity public class NewActivity extends Activity { @Ov ...
- 数据库——MySQL——多表查询
这里多表,为了方便我只建了两张表,更复杂的表间也就是这些东西,就是复杂程度不一样. 数据源准备 建立一个学生表,和一个班级表 # 建立学生表 create table student( id int ...
- oracle 分组函数、视图
组函数 分组函数作用于一组数据,对每一组返回一个值 组函数类型: 1.计数 count(列名 或 表达式) 对满足的行数进行统计 2.求和 sum(列名 或 表达式 ...
- Oracle 反向索引(反转建索引) 理解
一 反向索引 1.1 反向索引的定义 反向索引作为B-tree索引的一个分支,主要是在创建索引时,针对索引列的索引键值进行字节反转,进而实现分散存放到不同叶子节点块的目的. 1.2 反向索引针对的问题 ...
- 统计iOS产品不同渠道的下载量
如何统计iOS产品不同渠道的下载量? 一.前言 在开发过程中,Android可能会打出来很多的包,用于标识不同的商店下载量.原来觉得苹果只有一个商店:AppStore,如何做出不同来源的统计呢?本篇文 ...
- Python的核心数据类型
Python的核心数据类型有:数字,字符串,列表,字典,元组,文件等. 数字 数字类型有:整形int,浮点型float,复数complex,布尔型bool. 整形 整型数是不带有小数部分的 ...
- sax技术解析xml下jaxp解析器详细代码
*解析xml的两种技术dom和sax dom:根据xml的层级结构在内存中分配一个树形结构,把xml标签,属性,文本封装成对象. sax方式:事件驱动,边读边解析. 在javax.xml.parser ...
- 虚拟机服务没有启动的 CentOS 和 Ubuntu 无法上网
测试用 vmware 安装 OSX,安装补丁时要停止 vmware 的服务.如下图: 结果忘记启动了,导致 centos\ubuntu 等所有虚拟机都无法上网...所有的 启动这四个服务后,一切恢复正 ...
- array_x
import java.util.*; public class array_x { public static void main(String args[]) { int a[][]={{2,4, ...
- sort函数
做项目的时候,排序是一种经常要用到的操作.如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的时间,还很有可能写错.STL里面有个sort函数,可以直接对数组排序,复杂度为n ...