UI与数据分离 与 UI的演进
解藕的好处:UI内部模块能够灵活的变化。
MVC或者三层架构着重强调了数据、业务逻辑和UI的分离。
(MVC中的C只是UI和业务逻辑模块间的一个中转组件,理论上应该是个轻模块。)
以前的关注的解藕技术比耦合多;重点强调了现实与数据、业务逻辑的解藕;现实与数据的耦合则很少关注。
UI展示的主要工作:内容、样式、布局。
视图的分类:
简单视图:单一信息源视图;uilabel、uiiamgeview
符合视图:数据源为结构体;
数据源类型:
可配置;
不可配置;
UI布局的定制需求:需要开放接口给外面。
View开发定式:
1)配置子视图;loadSbuviews configSubviews
2)配置布局; 自动布局 layoutsubviews;
3)配置数据; loadDatas; 如果使用自动布局,配置数据后不用进行二次布局;否则需要二次布局。
数据配置与在MVC中的位置。
数据配置接口是视图层与业务逻辑层的接口。
理论上只有与业务逻辑有关的视图需要有这个接口。
UI的大部分功能还是信息展示和用户交互。
系统UI的支持(UIView):
事件处理:UIView : UIResponder
视图布局UIView(UIViewGeometry)
UIView (UIConstraintBasedLayoutCoreMethods)
视图组合:UIView(UIViewHierarchy)
视图样式(渲染):(UIViewRendering)
系统UI的数据接口支持(uilabel):
数据: @property(nullable, nonatomic,copy) NSString *text;
样式: @property(null_resettable, nonatomic,strong) UIFont *font;
@property(null_resettable, nonatomic,strong) UIColor *textColor;
@property(nullable, nonatomic,strong) UIColor *shadowColor;
@property(nonatomic) CGSize shadowOffset;
MVC中的C:主要工作是UI导航。
https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html#//apple_ref/doc/uid/TP40009503-CH5-SW6
Checklist for Implementing a Custom View
The job of a custom view is to present content and manage interactions with that content. The successful implementation of a custom view involves more than just drawing and handling events, though. The following checklist includes the more important methods you can override (and behaviors you can provide) when implementing a custom view:
- Define the appropriate initialization methods for your view:
- For views you plan to create programmatically, override the initWithFrame: method or define a custom initialization method.
- For views you plan to load from nib files, override the initWithCoder: method. Use this method to initialize your view and put it into a known state.
- Implement a dealloc method to handle the cleanup of any custom data.
- To handle any custom drawing, override the drawRect: method and do your drawing there.
- Set the autoresizingMask property of the view to define its autoresizing behavior.
- If your view class manages one or more integral subviews, do the following:
- Create those subviews during your view’s initialization sequence.
- Set the autoresizingMask property of each subview at creation time.
- If your subviews require custom layout, override the layoutSubviews method and implement your layout code there.
https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html#//apple_ref/doc/uid/TP40009503-CH5-SW6
Views
Because view objects are the main way your application interacts with the user, they have many responsibilities. Here are just a few:
- Layout and subview management
- A view defines its own default resizing behaviors in relation to its parent view.
- A view can manage a list of subviews.
- A view can override the size and position of its subviews as needed.
- A view can convert points in its coordinate system to the coordinate systems of other views or the window.
- Drawing and animation
- A view draws content in its rectangular area.
- Some view properties can be animated to new values.
- Event handling
- A view can receive touch events.
- A view participates in the responder chain.
This chapter focuses on the steps for creating, managing, and drawing views and for handling the layout and management of view hierarchies. For information about how to handle touch events (and other events) in your views, see Event Handling Guide for UIKit Apps.
UI与数据分离 与 UI的演进的更多相关文章
- jQuery MiniUI开发系列之:UI和数据分离
使用MiniUI需要注意:UI和数据是分离的. 传统的WEB开发,开发者经常将数据库操作.服务端业务.HTML标签写在一个页面内. 这样会造成开发的混乱,并且难以维护和升级. 使用MiniUI开发的时 ...
- WPF MVVM UI分离之《交互与数据分离》
在我们使用WPF过程中,不可避免并且超级喜欢使用MVVM框架. 那么,使用MVVM的出发点是视觉与业务逻辑分离,即UI与数据分离 诸如下面的问题: 删除操作,假如需要先执行一部分数据的处理,然后删除界 ...
- WPF MVVM UI分离之《交互与数据分离》 基础才是重中之重~delegate里的Invoke和BeginInvoke 将不确定变为确定系列~目录(“机器最能证明一切”) 爱上MVC3系列~全局异常处理与异常日志 基础才是重中之重~lock和monitor的区别 将不确定变成确定~我想监视我的对象,如果是某个值,就叫另一些方法自动运行 将不确定变成确定~LINQ DBML模型可以对
WPF MVVM UI分离之<交互与数据分离> 在我们使用WPF过程中,不可避免并且超级喜欢使用MVVM框架. 那么,使用MVVM的出发点是视觉与业务逻辑分离,即UI与数据分离 诸如下 ...
- WPF / Win Form:多线程去修改或访问UI线程数据的方法( winform 跨线程访问UI控件 )
WPF:谈谈各种多线程去修改或访问UI线程数据的方法http://www.cnblogs.com/mgen/archive/2012/03/10/2389509.html 子线程非法访问UI线程的数据 ...
- JQuery Easy Ui dataGrid 数据表格 ---制作查询下拉菜单
JQuery Easy Ui dataGrid 数据表格 数据表格 - DataGrid 继承$.fn.panel.defaults,使用$.fn.datagrid.defaults重载默认值.. 数 ...
- Android实战开发租赁管理软件(适配UI,数据的存储,多线程下载)课程分享
亲爱的网友,我这里有套课程想和大家分享,假设对这个课程有兴趣的,能够加我的QQ2059055336和我联系. 课程内容简单介绍 我们软件是基于移动设备的.所以我们必定的选择了安卓作为我们的开发工具.课 ...
- 【微信小程序】数据与界面UI不同步,不能直接操作Page.data
问题:数据层与UI不同步 微信小程序也采用UI绑定数据源的形式,根据以前做WPF的经验,直觉上认为修改了数据层(Page.data)后,UI会自动更新,然而实验发现数据层修改后UI层未修改,导致数据层 ...
- 关于mvvm:UI、数据、绑定、状态、中间变量、数据适配、数据处理
绑定: UI控件 --> VM VM -> UI控件 关于mvvm:UI.数据.绑定.状态.中间变量.数据适配.数据处理: https://github.com/zzf073/Log ...
- IOS开发UI基础--数据刷新
IOS开发UI基础--数据刷新 cell的数据刷新包括下面几个方面 加入数据 删除数据 更改数据 全局刷新方法(最经常使用) [self.tableView reloadData]; // 屏幕上的全 ...
随机推荐
- 利用jQuery实现鼠标滑过整行变色
在很多网站都有这样的效果,那就是当鼠标放在新闻列表一行上的时候,整行就会变色,虽然使用CSS也能够实现此种功能,但是由于众多浏览器版本对于CSS3并没有良好的支持,所以在当前情况下,使用jQuery实 ...
- 使用 Addr2line 将函数地址解析为函数名
用 Addr2line 将函数地址解析为函数名 原文链接:http://www.ibm.com/developerworks/cn/linux/l-graphvis/ Addr2line 工具(它是标 ...
- 7.13实习培训日志 Docker
静态博客github地址 静态博客github地址轻量版 Docker Docker镜像 Docker镜像概念 Docker镜像下载时的分层体现:一层层下载,下载过程中给出了每一层的 ID 的前 12 ...
- UVaLive 4727 Jump (递推)
题意:约瑟夫环,求最后三个数. 析:f[i] = (f[i-1] + k) % i 这是求最后一个数时候,我们倒着推到第一个数时,只有一个数,所以当只有两个数时,就是另一数, 同理,我们可以求得第三个 ...
- Sharepoint2013搜索学习笔记之设置业务数据内容源(六)
Sharepoint搜索爬网组件支持爬Business Data Connectivity Service 承载的外部数据,关于Business Data Connectivity Service设置 ...
- C++ - main()函数参数
main()函数及其参数说明 main()函数主要形式: int main(void) int main(int argc, char *argv[]) = int main(int argc, ch ...
- Lightoj1007【欧拉函数-素数表】
基础题. PS:注意unsigned long long; 以及%llu #include<bits/stdc++.h> using namespace std; typedef unsi ...
- TCP/IP之大明邮差
大明王朝天启四年, 清晨. 天色刚蒙蒙亮,我就赶着装满货物的马车来到了南城门, 这里是集中处理货物的地方 , 一队一队的马车都来到这里, 城头的士兵带着头盔,身披盔甲, 手持长枪, 虎视眈眈的注视这下 ...
- keycode和which
firefox 中不支持keyCode ie9-- 不支持which firefox:上下左右键会触发kepress. chrome: 上下左右键不会触发kepress. oprea:上下左右键不会触 ...
- codeforces 352D - Jeff and Furik【期望dp】
首先恋人操作过一轮之后逆序对不会变多,所以设f[i]为把i个逆序对消掉的期望次数,f[i]=0.5f[i-2]+0.5f[i]+2,化简然后递推即可 #include<iostream> ...