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]; // 屏幕上的全 ...
随机推荐
- java中多个线程访问共享数据的方式有哪些
多个线程对共同数据的访问的实现,要根据情况而定 (1)当访问共同的代码的时候:可以使用同一个Runnable对象,这个Runnable对象中有这个共享数据,比如卖票系统就可以这么做.或者这个共享数据封 ...
- LeetCode: 383 Ransom Note(easy)
题目: Given an arbitrary ransom note string and another string containing letters from all the magazin ...
- asp.net清空页面上的所有TextBox
Asp.net中一次性清空页面上的所有TextBox中的内容,由于TextBox在客户端以<input type=”text”>形式来呈现的,因此解决方案有客户端和服务器端两种方式,服务器 ...
- char和nchar,varchar和nvarchar的区别(转载)
1) 定义: char: 固定长度,存储ANSI字符,不足的补英文半角空格. nchar: 固定长度,存储Unicode字符,不足的补英文半角空格 varchar: 可变长度, ...
- 转载-聊一聊深度学习的activation function
目录 1. 背景 2. 深度学习中常见的激活函数 2.1 Sigmoid函数 2.2 tanh函数 2.3 ReLU函数 2.4 Leaky ReLu函数 2.5 ELU(Exponential Li ...
- uoj#278. 【UTR #2】题目排列顺序(拓扑排序)
传送门 对于每一个位置\(i\)来说,上一个和它的\(f_i\)相同的点一定比它大,我们从上一个\(f_i\)和它相同的点向它连边.第一个\(f_i-1\)出现的位置一定比它小,把它向那个位置连边. ...
- 利用sizeof,得到二维数组的维度
#include <iostream> #include <stdlib.h> using namespace std; int main() { ][]; cout < ...
- HDU-1068-GirlsandBoys(最大独立集,二分图匹配)
链接:https://vjudge.net/problem/HDU-1068#author=0 题意: 学校对n个学生(男女都有)进行的调查了,发现了某些学生暗生情愫,现在需要你选出一个最大的集合,这 ...
- Git关于Tag操作
Git关于tag的操作 记录下git关于 tag的操作 列出所有标签 git tag : 列出所有的 git tag -l 'v1.2.4.*' : 最后一位任意匹配 新建标签 git tag -a ...
- LNMP下使用Phabricator(一)
首先是安装. 安装过程并不复杂,英文看得懂的可以自己看原文 https://secure.phabricator.com/book/phabricator/article/installation_g ...