五分钟,运用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文件布局可以直接移植到移动端下面!

时间: 2024-08-06 22:39:25

五分钟,运用cocoaui库,搭建主流iOS app中我的界面的相关文章

iOS App中 使用 OpenSSL 库

转自:http://blog.csdn.net/kmyhy/article/details/6534067 在你的 iOS App中 使用 OpenSSL 库 ——译自x2on的“Tutorial: iPhone App with compiled OpenSSL 1.0.0a Library” 原文地址:http://www.x2on.de/2010/07/13/tutorial-iphone-app-with-compiled-openssl-1-0-0a-library/,本文有少许地方做

在你的 iOS App中 使用 OpenSSL 库

在你的 iOS App中 使用 OpenSSL 库 ——译自x2on的“Tutorial: iPhone App with compiled OpenSSL 1.0.0a Library” 原文地址:http://www.x2on.de/2010/07/13/tutorial-iphone-app-with-compiled-openssl-1-0-0a-library/ ,本文有少许地方做了调整. 1.下载OpenSSL源代码库: http://www.openssl.org/source/

在iOS App 中添加启动画面

你可以认为你需要为启动画面编写代码,然而Apple 让你可以非常简单地在Xcode中完成.不需要编写代码,你仅需要在Xcode中进行一些配置. 1.什么是启动画面(Splash Screen)? 启动画面是你在启动App的时候看到的第一个界面,通常,启动画面是覆盖整个屏幕的一张图片,在主屏幕装在完后隐藏. 启动画面的主要目的是让用户知道你的App正在装载,并且对用户介绍你的品牌.启动画面对哪些需要较长时间启动的Apps尤其重要.一般而言,启动画面是为了给用户更好的体验. 2.在你的App中添加启

如何在 iOS App 中整合 Facebook 廣告

原文:Displaying Facebook Ads in Your iOS Apps 作者:GABRIEL THEODOROPOULOS 译者:kmyhy 不久前有人問我如何在項目中集成 Facebook 的廣告.因為之前沒用過,以為一定很難,所以事先查閱了大量文檔.在通讀完文檔之後,發現其實並不是很難,僅僅幾分鐘我就能夠搞定我的第一個 Facebook 廣告 App! Facebook 廣告是一種將廣告集成到你的 app 中的方法,使你可以通過廣告的點擊量來獲得收入.這個方法(集成廣告)并不

关于iOS APP中网络层的设计

在iOS开发中,请求网络数据,处理获得的数据是很常见的功能,但是很少有资料会讨论关于网络的处理应该放在MVC中得哪个层中. 我在网上Google了一番,记下了几个觉得比较不错的链接.现记录如下: http://stackoverflow.com/questions/4810289/best-architecture-for-an-ios-application-that-makes-many-network-requests?lq=1 这个答案提供了一个实际的设计 http://akosma.c

iOS APP中第三方APP调用自己的APP,打开文件

根据需求需要在项目中要打开word.pdf.excel等文件,在info.plist文件中添加 <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string></string> <key>LSItemContentTypes</key> <array> <strin

(转)IOS App中揉合讯飞SDK功能详细

转至:http://www.sufeinet.com/thread-2488-1-1.html 如何使用讯飞的语音SDK加入到你的iPhone应用中吧!1.首先请先到讯飞官方网站的开发者专区(http://open.voicecloud.cn/developer.php).如果你还没有注册,那么需要先注册一个开发者账号的.点击网站顶部的"免费注册"即可,使用你的自己的手机号码注册一个账号.2.仅仅注册了一个开发者账号还可以使用SDK,因为还需要申请Appid.登陆之后到自己的个人中心创

iOS APP中数据加载的6种方式

我们看到的APP,往往有着华丽的启动界面,然后就是漫长的数据加载等待,甚至在无网络的时候,整个处于不可用状态.那么我们怎么处理好界面交互中的加载设计,保证体验无缝衔接,保证用户没有漫长的等待感,而可以轻松自在的享受等待,对加载后的内容有明确的预期呢? 设计师在进行APP设计的设计时,往往会更加专注于界面长什么样,界面和界面之间怎么跳转,给予用户什么样的操作反馈,却偏偏特别容易忽略掉一个比较重要的环节,就是APP数据加载中的设计,所以会导致我们看到的APP,往往有着华丽的启动界面,然后就是漫长的数

Git五分钟教程

许多人认为Git太混乱或是复杂的版本控制系统,这篇文章是面向一些人想快速上手使用Git, 对于大多数基本需求这篇文章涵盖了使用的70%至90% 入门 使用Git前 需要先建立一个仓库(repository).你可以使用一个已经存在的目录作为Git仓库或创建一个空目录 使用您当前目录作为Git仓库,我们只需使它初始化 git init 使用我们指定目录作为Git仓库 git init newrepo 从现在开始,我们将假设你在Git仓库根目录下,除非另有说明 添加新文件 我们有一个仓库,但什么也没