五分钟,运用cocoaui库,搭建主流iOS app中我的界面
本项目基于天天团购项目,在上一篇中有说到!
首先介绍一些cocoaui,是国内的一名程序员做的开源的开源系统,目的是为了简化ios布局!官网地址:www.cocoaui.com,github地址:https://github.com/ideawu/cocoaui
我们这里使用xml定义布局界面,其实就是传统的html + css定义界面,大部分人都有网页布局的经验,搞ios布局还是很容易入手并且快捷的!我们首先看下我们要做的界面:

我们按照html+css的格式来定义这个界面:
<div>
<style>
.headDiv
{
width:100%;
}
.divStyle{
width:100%;
height:auto;
border-bottom: 1 solid #eee;
background:#fff;
vertical-align:middle;
}
.subdivStyle
{
height:auto;
border: 1 solid #eee;
height:40px;
background:#fff;
}
.textStyle{
float:left;
height:40px;
valign:middle;
}
.btnStyle
{
background:#EDA67B;
width:80%;
height:50px;
float:center;
}
</style>
<div id="headContent" class="headDiv">
<img id="profileHeader" style="width:80px;height:80px;float:center;margin:10px;" src="default_head.png" />
</div>
<div id="myWashCar" class="subdivStyle" style="width:50%;height:80px;">
<img style="margin:10px;width:50px;height:50px;valign:middle;" src="ic_mt_coupon" />
<span type="text" class="textStyle" >消费卷</span>
</div>
<div id="myCoupon" class="subdivStyle" style="width:100%;height:80px;">
<img style="margin:10px;width:50px;height:50px;valign:middle" src="ic_user_main_favorite.png" />
<span class="textStyle" style="vertical-align:middle;" >我的收藏</span>
</div>
<div id="myCar" class="divStyle">
<img style="margin:10px" src="myfollow.png" />
<span type="text" class="textStyle">我的订单</span>
<img style="float:right;margin:10px;" src="ic_arrow.png" />
</div>
<div id="myMsg" class="divStyle">
<img style="margin:10px" src="mylike.png" />
<span class="textStyle">我的评价</span>
<img style="float:right;margin:10px;" src="ic_arrow.png" />
</div>
<div id="myVersion" class="divStyle">
<img style="margin:10px" src="moreitems_version.png" />
<span type="text" class="textStyle">版本更新</span>
<img style="float:right;margin:10px;" src="ic_arrow.png" />
</div>
</div>
将其命名为profile.xml文件放到工程中。格式是不是和普通的html+css界面一模样!支持大部分的html标记和css属性!
然后在ProfileViewController中引入profile.xml文件:代码如下:
- (void)viewDidLoad
{
[super viewDidLoad];
[self initSystemBtn];
root = [IView namedView:@"profile.xml"];
[self addIViewRow:root];
[self reload];
[self initEvent];
}
点击头像需要进入修改玩家信息界面,需要监听头像的点击事件:
-(void)initEvent
{
__weak typeof(self) me = self;
IImage *profileHeader = (IImage *)[root getViewById:@"profileHeader"];
[profileHeader addEvent:IEventClick handler:^(IEventType type,IView *view){
[me gotoProfileEdit];
}];
}
是不是很简单就能定义一个界面!
补充
1:对SdWebImage的支持,IImage(UIImageView的再次封装)中暴露了UIIMageView的接口,可以方便的使用sdWebImage,开始是不支持的,和作者沟通了一下,暴露了这个接口!
2:对上拉刷新和下拉加载的支持。有例子为证:http://www.cocoaui.com/docs/api/IRefreshControl
3: 对于webview的支持!控件中没有对于webview的支持,如果页面中需要嵌入webview则需要动态创建!
4:对于radio和checkbox的支持,目前还不支持,需要动态创建,不过非常easy!
5: 由于很多app 都需要微信端,xml文件布局可以直接移植到移动端下面!
五分钟,运用cocoaui库,搭建主流iOS app中我的界面的更多相关文章
- iOS App中 使用 OpenSSL 库
转自:http://blog.csdn.net/kmyhy/article/details/6534067 在你的 iOS App中 使用 OpenSSL 库 ——译自x2on的“Tutorial: ...
- 在iOS APP中使用H5显示百度地图时如何支持HTTPS?
现象: 公司正在开发一个iOSAPP,使用h5显示百度地图,但是发现同样的H5页面,在安卓可以显示出来,在iOS中就显示不出来. 原因分析: 但是现在iOS开发中,苹果已经要求在APP中的所有对外连接 ...
- 关于iOS APP中网络层的设计
在iOS开发中,请求网络数据,处理获得的数据是很常见的功能,但是很少有资料会讨论关于网络的处理应该放在MVC中得哪个层中. 我在网上Google了一番,记下了几个觉得比较不错的链接.现记录如下: ht ...
- 在iOS App 中添加启动画面
你可以认为你需要为启动画面编写代码,然而Apple 让你可以非常简单地在Xcode中完成.不需要编写代码,你仅需要在Xcode中进行一些配置. 1.什么是启动画面(Splash Screen)? 启动 ...
- 五分钟用Docker快速搭建Go开发环境
挺早以前在我写过一篇用 `Docker`搭建LNMP开发环境的文章:[用Docker搭建Laravel开发环境](http://mp.weixin.qq.com/s?__biz=MzUzNTY5MzU ...
- 只需五分钟-用Maven快速搭建Spring Cloud微服务
Maven安装手册 1.准备安装包 安装包: apache-maven-3.5.4-bin.zip (最好JDK 1.7及以上版本) 集成包: eclipse-maven3-plugin.zip 2 ...
- [置顶] ios App 中嵌入应用商店
昨晚同事拿了一个app 发现其app 内部页面打开了appstore 并没有唤起手机自带的appstore, 刚开始以为是用webview 加载的 ,可是自己些了一个demo 发现并不是那样一回事 用 ...
- 新手介绍简单一下iOS开发中几种界面传值
首先在处理iOS-UI中,也许在很多地方需要用到两种甚至多种不同界面之间的传值,相比这也是很多iOS入门成员头疼问题,同样作为新手的我在接触这类传值时候也一脸懵然,经过一段时间的研究,对于简单的传值有 ...
- iOS APP跳转设置界面以及设置中的其他界面
1.跳转设置总页面(iOS10+以及之前的都可以用:ios10+ 是跳转到了应用到设置界面) [[UIApplication sharedApplication]openURL:[NSURL URLW ...
随机推荐
- Android——程序移植 相关知识总结贴
android 移植笔记有感 http://www.apkbus.com/android-11842-1-1.html Android振动器系统结构和移植和调试 http://www.apkbus ...
- Codeforces Round #160 (Div. 1) 题解【ABCD】
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...
- nodejs 的安全
1.connect中间件csrf 原理:在express框架中csrf 是通过connect 模块的中间件来解决的.其原理是在前端构造一个隐藏的表单域“_csrf” ,后端生成一个值,作为该表单域,然 ...
- 简明易懂的call apply
在iteye看到一篇对call解释得相当简明易懂,觉得得宣传一下 : http://uule.iteye.com/blog/1158829 一.方法的定义 call方法: 语法:call([thisO ...
- 值得一看:利用对标帮助客户进行GAP分析,找到业务发展方向!
最好是跟CBM一起来使用. Presentation Here: https://ibm.biz/BdXJrQ CAN ONLY ACCESS at IBM internal.
- centos 7 /etc/rc.local 开机不执行的问题
最近发现centos7 的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了 1 2 3 4 5 6 7 8 9 10 11 #!/bin/ ...
- Notes on how to use Webots, especially how to make a robot fly in the air
How to create a new project Wizard - New project directory Scene Tree Scene tree is a representati ...
- C++读取mysql中utf8mb4编码表数据乱码问题及UTF8转GBK编码
数据库编码为utf8,但是由于某些表的一些字段存储了emoji字符,表采用了utf8mb4编码,默认情况下在C++代码中读出的中文字段值都变成了乱码. 解决方法为,在进行数据库查询前,在C++中执行一 ...
- Apache+PHP+Mysql OS X 10.9 Mavericks WEB 服务器配置
在 OS X 10.9 上基本没有什么特别大的差异. 为了新系统用户方便小弟重新整理了一下,因为在 OSX 10.9 下的 Server 软件进行了不少升级,有些步骤不太一样了. 硬件方面就不在详细描 ...
- git Please move or remove them before you can merge. 错误解决方案
git pull 时 往往会遇到各种各样的问题 ,下面是常遇到的一种状况 Updating 7c9e086..936acacerror: The following untracked working ...