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]; // 屏幕上的全 ...
随机推荐
- [Oracle]oracle查询表列名、及列数
--查询表列数 select count( column_name ) from user_tab_columns where table_name = 'CJ_HOME_MEDICAL_RECORD ...
- 大话Spark(1)-Spark概述与核心概念
说到Spark就不得不提MapReduce/Hadoop, 当前越来越多的公司已经把大数据计算引擎从MapReduce升级到了Spark. 至于原因当然是MapReduce的一些局限性了, 我们一起先 ...
- Vue+Electron下Vuex的Dispatch没有效果的解决方案
这个问题是解决基于 vue 和 electron 的开发中使用 vuex 的 dispatch 无效的问题,即解决了 Please, don't use direct commit's, use di ...
- 自定义Swap
网上看到的一篇文章加深了对指针的了解,收藏一下 自定义的swap函数是一个老掉牙的问题,而这个问题对于理解指针和内存中的栈是很有帮助的 一般自定swap函数是这样的: 1.swap函数的功能是实现两个 ...
- java接口中成员变量和方法的默认修饰符(转)
Java的interface中,成员变量的默认修饰符为:public static final 所以我们在interface中定义成员变量的时候,可以 1:public static final St ...
- Animation Starter Pack中动画蓝图事件添加的位置
可以直接在动画状态机的详情页添加简单事件,跟在动画里添加的通知事件效果一致
- [转] 深度探索Hyperledger技术与应用之超级账本的典型交易流程
转自: https://blog.csdn.net/HiBlock/article/details/80212499 个人感觉对交易流程描述的比较清楚,转载以备查看. 1 典型交易流程 下图所示为Hy ...
- uoj#349. 【WC2018】即时战略(动态点分治)
传送门 头一次看着题解有一种咱不会\(c++\)的感觉-- 看题解吧-- //minamoto #include<bits/stdc++.h> #include "rts.h&q ...
- git clone 指定新建本地库位置
- Jmeter—生成excel结果文件
相信很多用jmeter进行接口测试的童鞋都会有这样的苦恼:同时执行上百条测试案例,如何能轻松加愉快地检查案例输出结果?仅仅靠jmeter的断言.debug sampler.察看结果树等是无法满足我们要 ...