毕业设计(论文)-基于ObjectC的IOS项目(图游旅行)的实现.docx_第1页
毕业设计(论文)-基于ObjectC的IOS项目(图游旅行)的实现.docx_第2页
毕业设计(论文)-基于ObjectC的IOS项目(图游旅行)的实现.docx_第3页
毕业设计(论文)-基于ObjectC的IOS项目(图游旅行)的实现.docx_第4页
毕业设计(论文)-基于ObjectC的IOS项目(图游旅行)的实现.docx_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

洛阳师范本科毕业设计2015届本科毕业设计基于object-c的ios项目(图游旅行)的实现院 (系) 名 称物理与电子信息学院专 业 名 称过程控制学 生 姓 名学 号指 导 教 师完 成 时 间2015年5月10日基于object-c的ios项目的实现物理与电子信息 过程控制方向 学号:110544137指导教师;摘要:基于对c,object-c的深入研究进而对ios项目的探究,通过对项目的研究主要对于c的逻辑深入运算和对oc语法的探究以及各种方法及其操作响应,主要是为了体会面向对象的思想以及对于ios方法,逻辑上的调用。通过对项目的研究更好地了解为何iphone,ipad等系列的发展如此的迅速,深入探讨整个项目的运行,更好地体会面向对象的编程思想,在项目中如何更好地做到精简,合理,有效,对于一个好的程序设计师是非常有必要的;关键字:ios ,oc xcode 设计思想based on object-c realize iphone operating system chen zhong -mincollege of physics and electronic information physics no: 110544137tutor: chen leiabstract: based on the in-depth study of c, object-cs turn to explore the ios project, through the study of the projects main logic for c operation and thorough inquiry object- grammar and various methods and operation response, mainly to experience object-oriented thinking and methods for ios, call logic. why is the study of the project to better understand the iphone, ipad and other series of growing so rapidly, depth operation of the entire project, a better feel for the object-oriented programming ideas, in a project to streamline how best to achieve reasonable and effective procedures for a good designer is very necessary;keywords: iphone operating system xcode design idea目录基于object-c的ios项目(图游旅行)的实现11.引言31.1 项目研发的背景41.2 项目研发的意义42.项目需求分析42.1 项目简要需求分析43.项目的详细分析53.1 项目启动前的准备53.2 项目过程中得详细设计54.项目的重要代码的实现74.1主界面的设计84.2 界面跳过加载124.3支付宝的调用234.4数据持久化(沙盒的运用)265.项目的优化285.1代码冗余处理285.2 优化适配286总结28参考文献291. 引言1.1 项目研发的背景 针对本次的app的研发,背景:目前市场的开发对于火车票的订购在之前的时候是只有12306的订票系统,对于飞机机票和酒店的机票的预定更是只能到航空机场或者是打电话预定,对于这种传统的销售车票的模式,在很大的程度上阻碍了老百姓很难在有效的时间买到票,首先是针对火车票的预定在之前的预定的火车票的过程中,很多人都是12306进行车票的预定,更有甚者有大量的黄牛党,倒卖车票的行为,对于那些文化程度低和对网络接触比较限制的人们更不容易买到有效价格合适的票价,更有对于农民更是一种困难,对于飞机票更是难以想象,大多数的人都是认为机票的票价昂贵,在此之前预定机票都是通过电话或者通过在各个航空公司预定机票,不能得到正确地票价的比较和流程,所以造成了让人们意识到,飞机的票价高,不方便买票的意识,而对于酒店的预定,当你坐飞机或者火车到达你所到达的地点时,如果此时你想在预定酒店的预定,就会产生很多不必要的麻烦,所以针对本文以上的说法,针对传统的售票的模式,顾客一时难以在有效的时间里买到自己需要的票,二是即使买到票也不能有效的比较日期和价格,1.2 项目研发的意义 为人们的出行造成了很大的不方便,针对本次app的意义就是在于对于各个的航空公司,铁道和酒店等各个方面一条龙的服务,主要是对信息的整合,让人们能够更好地把握自己所需要的信息,从而能够更好地出行。针对目前对于这一方面目前市场上对于这方面还是有很大的需求的,在这方面上做的也比较好的就是携程和去哪儿,大多数人认为这是一个旅游性质的app,其实还有更多地用途,在下面本文会给大家有详细的解说。但是还是有很大的发展空间很多的人不知道这方面的资源的利用,所以本文很有必要对这个进行一个深入的研究,对此在当前领域已经有很多的公司对此有一个很大的进步,对此我觉得在机票和车票等票的系统的售卖是一个很有必要的趋势,从而推动整个产业的发展,从而本文研发的app主要是针对代理商的app。2. 项目需求分析 2.1 项目简要需求分析对于此次的项目,在可行性上是可以的,对于广大群众来说这个是非常有必要的,目前很多的人都是需要的,对于长远角度来说,对于手机app的定做也是非常有必要的,能够使用于很多对于电脑操作不方便的客户和更多希望节省大量时间的客户,适用于很多出行旅行和长途出差。是出行必不可少的。对于价格的只管比较和对时间的更好地选择都是客户比较好的选择。对于项目的实现主要是分成主要的三个模块,其余的是装饰的模块,主要是机票模块,火车票的模块和酒店的模块,对于每个模块主要的是对页面的展示,主要是各个起始点的价格,地点等展示然后就是各个行程的详细信息,以及最后的支付等功能,已经对支付宝的调用,在对第三方框架的调用上,必须保持最新的版本控制以及数据的获取都是要后台人员进行详细的沟通。在此处只是系统大概的讲解了项目的需求,细致的项目分析需求在下文会有详细的分析;3. 项目的详细分析3.1 项目启动前的准备由于项目太大的原因,本文在此细致的讲解一个模块以及主模块的内容,其他的项目内容课一参看这个模块的内容。首先对于一个app而言,首先要做到的就是真机测试,真机测试之前需要申请开发者的账号,对于开发者的账号需要的流程也是比较繁杂的,但是你只要按照步骤来走,基本上是都可以成功的,(我当时出现的问题就是在信用卡的使用上出现的问题,对于这个问题,大家可以提前的百度一下),必须是支持货币转换的visa卡,这个是必须注意的,详细步骤在我滞后会有详细的参考文档。对于真机测试的步骤我在此就不详细的说明了,对于真机测试我真的觉 得有时候是很扯淡的,尤其是在获取真机的测试的证书的时候,在这里很是需要大家进行参考下,在做这个之前必须是要把自己的电脑要清楚所有的证书,已确保获取证书的保证,在这一点上苹果公司我觉得是做的相当好的,(百度搜索apple developer);3.2 项目过程中得详细设计首先首先在app设置之前需要设置app的图标,由于在不同的手机屏幕上需要适配不同的尺寸,所以针对这个要求,需要三个尺寸的app的图标(因为目前主要的是三个尺寸)。后面还有介绍手机的适配(也是需要多个尺寸的,这个在后面讲)。这些都是在制作一个app之前不许要满足的要求(有一个mac是必须的这个不用我说了,如果没有的话,你可以自己装一个黑苹果);之后的设置就是app启动的图片的制作,这个是和图标的制作也是一样的也是需要不同的尺寸,只需要在目录上打开相应地设置然后加入自己的想要的图片(这里需要注意的就是注意图片的尺寸,如果出现错误是会出现相关的警告的,到时候你自己就会看见),在此你要是想自己做一个连续的启动的动画的话,这个就需要在代码中设计了,设计成滚动的模式,如果你需要更新的话,还需要与后台进行连接,这个需要你和后台的服务器进行连接的,基本上也不是很难得。做好这些基本准备的话 ,你的手机上基本就有了一个app大概的框架了 可以开启并且有启动的动画,之后就进入到正文了就是代码和需求的设计了,需要认真地考虑和设计了,在此首先得设计,项目的主界面在这个主界面的设置当中就是有你像设置的内容,飞机票,火车票,酒店的管理,自己公司的图标内容以及推广(具体的图片的设计在后面我会给出)在此主要的又三个模块,飞机票,火车票,酒店的管理,在点击进入之后会有一个登录的界面主要是对有账号的客户的一种保护,这个是需要和后台的服务器链接的,不过也是可以借助第三方的,可以进一步的加密,我在此是自己直接和自己的后台的服务器进行的链接,主要用到了技术是对导航栏设计,推向,以及plist文件的使用,tableview和plist的混合以及字典的混合运用,从后台获取数据,如何请求数据,最重要的是gcd多线程的处理这个是尤其重要的,在后面我会有相关的代码的展示,以及多按钮的响应,这里会设计到c语言的逻辑运算各种的逻辑的算法,排除,在这里我用了一个第三方的插件就是日历,这个日历当时是没做个适配的,这里是需要你做适配的,这个要注意,然后还有一个第三方的hud,这里需要是和gcd联合在一起使用的,是进行数据请求的过程中hud要运行,(这个在代码中也会有展示的),还有就是对一个按钮的动画的实现这个是需要使用好block的,(在这里block的使用时很重要的,不仅可以减少代码的使用量小并且简单方便)。然后就是在plist获取城市的时候,tableview的掌握是必须的,这里就不详细说了,有参考的文档,在城市的选择中有一个searchbar 对于searchbar的界面设计是没有什么可说的了,但是对于searchbar的内容设计需要在这里说一下,对于里面的查询内容的设计,主要是对oc的方法的设计以及大力方法的运用,在这里本文认为是一个难点,(下文有相关的代码的展示)。一般在设计hud的出现一般是要设计在第二个的页面上,在第二个页面一个是不会影响主线程的阻塞在一个就是不会让客户有等待的焦虑感。然后在获取到信息后就会得到你想要的信息(此处界面的ui设计以及各种的控件的设置我在这里就不一一说明了)更多地是细节的设置,这个是需要自己多注意的。在这里在数据的请求之后进入下,在页面的转换之间,需要注意的就是页面的传值,有属性传值,代理传值,block传值在正向的传值当中是用的是属性的处置,对于反向的传值我推荐的是block的传值,(原因本文已经在上面指出过),最后还需要说明的是在这里还需要单例传值,单例传值的好处也是很大的在这里就补一一说明了,下文会给出相关的文档,在页面的展示当中其中有tableview的展示是cell的自定义,在此本文要说明的是cell的重用机制需要注意下,但是对于cell的自定义是重用机制就要需要你慎用了。进入之后就是就是票价的预定了,在此其中,需要注意的就是对于数据的持久化,对于数据的持久化我使用的是沙盒,因为本文在此用的数的数据不是太大,如果要用到数据比较大的情况下就需要用数据库的形式了,以及对tableview的数据的多选以及内部数据的处理都是需要注意的。数据的持久化在这里也是需要注意的,对于沙盒的存取是重新写入,不会一次次的加入数值,后面最重要的部分就是支付宝的引入了,对于支付宝的引入,其中的步骤是比较繁杂的,在做的时候遇见最大的问题就是路径的问题,这个问题需要特别的注意一下,对于支付宝的版本问题也是需要特别的注意一下的,只有更新到最新的才能够调用你的支付宝,对于支付宝的步骤及其相关的操作也是比较复杂的,更具需求的文档按照步骤走,基本上是不会出现问题的。以上的所述只是在此项目中得一个模块,对于其他的模块和此模块都是类似,可以有参考和借鉴,具体的又细小的修改。在此就补一一列举内容了,在下一个部分将有代码的展示部分;4. 项目的重要代码的实现4.1主界面的设计 对于首页的设置,scrollview当时采用的是第三方的控件,具体的实现是部分地方中下面的代码是只需你写的代码:#pragma mark - 构建广告滚动视图- (void)createscrollview nslog(%f,height); scrollview = adscrollview allocinitwithframe:cgrectmake(0,64, self.view.frame.size.width,(100.0f/568.0f)*height); addatamodel * datamodel = addatamodel addatamodelwithimagenameandadtitlearray;/如果滚动视图的父视图由导航控制器控制,必须要设置该属性(ps,猜测这是为了正常显示,导航控制器内部设置了uiedgeinsetsmake(64, 0, 0, 0) scrollview.contentinset = uiedgeinsetsmake(0,0, 0, 0); scrollview.imagenamearray = datamodel.imagenamearray; scrollview.pagecontrolshowstyle = uipagecontrolshowstyleright; scrollview.pagecontrol.pageindicatortintcolor = uicolor whitecolor; / scrollview setadtitlearray:datamodel.adtitlearray withshowstyle:adtitleshowstyleleft; scrollview.pagecontrol.currentpageindicatortintcolor = uicolor purplecolor; self.view addsubview:scrollview;2,在进入到登陆的按钮当中,主要是对控件的定位和适配,在这里本文主要的展示的是各个控件的适配,在这一方面本文主要采用的是nslayout /界面的适配 #pragma mark = /适配会员登录的图片 logoview.translatesautoresizingmaskintoconstraints=no; / nslayoutconstraint *logoconstraint1=nslayoutconstraint constraintwithitem:loginview attribute:nslayoutattributeright relatedby:nslayoutrelationequal toitem:loginview attribute:nslayoutattributeleft multiplier:1.0 constant:125; / nslayoutconstraint *logoconstraint2=nslayoutconstraint constraintwithitem:loginview attribute:nslayoutattributebottom relatedby:nslayoutrelationequal toitem:loginview attribute:nslayoutattributetop multiplier:1.0 constant:70; nslayoutconstraint *logoconstraint3=nslayoutconstraint constraintwithitem:self.view attribute:nslayoutattributecenterx relatedby:nslayoutrelationequal toitem:logoview attribute:nslayoutattributecenterx multiplier:1.0 constant:0; nslayoutconstraint *logoconstraint4=nslayoutconstraint constraintwithitem:self.view attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:logoview attribute:nslayoutattributetop multiplier:1.0 constant:-60; self.view addconstraints:logoconstraint3,logoconstraint4; #pragma mark = /适配登录的账号 yonghutext.translatesautoresizingmaskintoconstraints=no; nslayoutconstraint *yonghucontraint1=nslayoutconstraint constraintwithitem:yonghutext attribute:nslayoutattributeleft relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributeleft multiplier:1.0 constant:20; nslayoutconstraint *yonghucontraint2=nslayoutconstraint constraintwithitem:yonghutext attribute:nslayoutattributeright relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributeright multiplier:1.0 constant:-20; nslayoutconstraint *yonghucontraint3=nslayoutconstraint constraintwithitem:yonghutext attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:yonghutext attribute:nslayoutattributebottom multiplier:1.0 constant:-40; #warning - nslayoutconstraint *yonghucontraint4=nslayoutconstraint constraintwithitem:yonghutext attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:logoview attribute:nslayoutattributebottom multiplier:1.0 constant:80; self.view addconstraints:yonghucontraint1,yonghucontraint2,yonghucontraint3,yonghucontraint4; #pragma mark = /适配密码 mimatext.translatesautoresizingmaskintoconstraints=no; nslayoutconstraint *mimacontraint1=nslayoutconstraint constraintwithitem:mimatext attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:yonghutext attribute:nslayoutattributebottom multiplier:1.0 constant:10; nslayoutconstraint *mimacontraint2=nslayoutconstraint constraintwithitem:mimatext attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:mimatext attribute:nslayoutattributebottom multiplier:1.0 constant:-40; nslayoutconstraint *mimaconstraint3=nslayoutconstraint constraintwithitem:mimatext attribute:nslayoutattributeleft relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributeleft multiplier:1.0 constant:20; nslayoutconstraint *mimaconstraint4=nslayoutconstraint constraintwithitem:mimatext attribute:nslayoutattributeright relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributeright multiplier:1.0 constant:-20; self.view addconstraints:mimacontraint1,mimacontraint2,mimaconstraint3,mimaconstraint4; #pragma mark = /登录按钮的适配 denglubtn.translatesautoresizingmaskintoconstraints=no; nslayoutconstraint *buttonconstraint1=nslayoutconstraint constraintwithitem:denglubtn attribute:nslayoutattributeleft relatedby:nslayoutrelationequal toitem:denglubtn attribute:nslayoutattributeright multiplier:1.0 constant:-280; nslayoutconstraint *buttonconstraint2=nslayoutconstraint constraintwithitem:denglubtn attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:denglubtn attribute:nslayoutattributebottom multiplier:1.0 constant:-50; nslayoutconstraint *buttonconstraint3=nslayoutconstraint constraintwithitem:denglubtn attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:mimatext attribute:nslayoutattributebottom multiplier:1.0 constant:20; nslayoutconstraint *buttonconstraint4=nslayoutconstraint constraintwithitem:denglubtn attribute:nslayoutattributecenterx relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributecenterx multiplier:1.0 constant:0; nsarray *buttonconstraints=buttonconstraint1,buttonconstraint2,buttonconstraint3,buttonconstraint4; self.view addconstraints:buttonconstraints;#pragma mark适配登录下方的图片 sloganview.translatesautoresizingmaskintoconstraints=no; nslayoutconstraint *sloganconstraint1=nslayoutconstraint constraintwithitem:sloganview attribute:nslayoutattributeleft relatedby:nslayoutrelationequal toitem:sloganview attribute:nslayoutattributeright multiplier:1.0 constant:-160; nslayoutconstraint *sloganconstraint2=nslayoutconstraint constraintwithitem:sloganview attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:sloganview attribute:nslayoutattributebottom multiplier:1.0 constant:-30; nslayoutconstraint *sloganconstraint3=nslayoutconstraint constraintwithitem:sloganview attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:denglubtn attribute:nslayoutattributebottom multiplier:1.0 constant:40; nslayoutconstraint *sloganconstraint4=nslayoutconstraint constraintwithitem:sloganview attribute:nslayoutattributecenterx relatedby:nslayoutrelationequal toitem:self.view attribute:nslayoutattributecenterx multiplier:1.0 constant:0; nsarray *sloganconstrants=sloganconstraint1,sloganconstraint2,sloganconstraint3,sloganconstraint4; self.view addconstraints:sloganconstrants;3.在接受数据的过程中对数有一个简单地xml地解析在这里本文就不一一书写了在后面的文档本文可能会提到的4.2 界面跳过加载4.在进行界面的转换和hud的实现和请求数据,在这里会使用到多线程gcd,这一点是早ios开发的过程中是尤其重要的在这段代码里面我会展示的是用gdate解析文件,hud的展示,数据的请求以及和gcd的混合的运用:以及对日期的格式的处理的问题,吧全部的信息处理在一个按钮的时间当中,在这里需要细心的处理-(void)btn1test nslog(前天按钮); nslog(%,self.btn2.titlelabel.text); self.fightarr=nsmutablearray allocinit; gresshud=mbprogresshud allocinitwithview:self.view; self.view addsubview:gresshud; /遮罩 gresshud.dimbackground=yes; gresshud.labeltext=图游为您加载; /动画效果 gresshud.animationtype=mbprogresshudmodedeterminatehorizontalbar; /显示对话框 gresshud showanimated:yes whileexecutingblock: /对话框显示时需要执行的操作 时间为3秒 sleep(100); ; dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); dispatch_group_t group = dispatch_group_create(); dispatch_group_async(group, queue, if (self.buttontag=102) nslog(group1); nsdateformatter *dateformatter = nsdateformatter alloc init; dateformatter settimezone:nstimezone timezonewithabbreviation:utc; dateformatter setdateformat:yyyy-mm-dd; / 日期加 nsdate *date0 = nsdate allocinit; date0=dateformatter datefromstring:self.btn2.titlelabel.text; nstimeinterval interval =-60 * 60 * 24; qiantianstr = dateformatter stringfromdate:date0 initwithtimeinterval:interval sincedate:date0; self.xmlelement=nsxmlelement allocinit; self.myarr=nsmutablearray array; self.myarr2=nsmutablearray array; nsstring *path=nsstring stringwithformat:/platform/airflight!searchairflight.action?startairportcode=%&endairportcode=%&depdate=%&agentcode=qxcg10482,self.zhongdainstr,self.qianstr,qiantianstr; nsurl *url=nsurl urlwithstring:path; _autoreleasing nsurlresponse *response; _autoreleasing nserror *error; nsurlrequest *request=nsurlrequest requestwithurl:url cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:100; nsdata *xmldata=nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error; /使用nsdata对象初始化 gdataxmldocument *doc = gdataxmldocument alloc initwithdata:xmldata options:0 error:nil; /获取根节点(users) gdataxmlelement *rootelement = doc rootelement; /获取根节点下的节点(user) nsarray *flights = rootelement elementsforname:flight; self.fightnum=flights count; for (gdataxmlelement *fighlit in flights) / nsstring *arrname=fighlit attributeforname:arrname stringvalue;in nsstring *arrtime=fighlit attributeforname:arrtimestringvalue; nsstring *dpttime=fighlit attributeforname:dpttimestringvalue; nsstring *arrairport=fighlit attributeforname:arrairportstringvalue; nsstring *carrier=fighlit attributeforname:carrierstringvalue; nsstring *code=fighlit attributeforname:codestringvalue; nsstring *codeshare=fighlit attributeforname:codesharestringvalue; nsstring *fuel=fighlit attributeforname:fuelstringvalue; nsstring *price=fighlit attributeforname:pricestringvalue; nsstring *meal=fighlit attributeforname:mealstringvalue; nsstring *plantype=fighlit attributeforname:plantypestringvalue; nsstring *stops=fighlit attributeforname: stopsstringvalue; nsstring *tax=fighlit attributeforname:taxstringvalue; nsstring *arrairportname=fighlit attributeforname:arrairportnamestringvalue; nsstring *dptairportname=fighlit attributeforname:dptairportnamestringvalue; nsstring *carriername=fighlit attributeforname:carriernamestringvalue; nsmutabledictionary *tempdic=nsmutabledictionary dictionary; tempdic setobject:arrairportname forkey:arrairportname; tempdic setobject:dptairportname forkey:dptairportname; tempdic setobject:arrtime forkey:arrtime; tempdic setobject:dpttime forkey:dpttime; tempdic setobject:arrairport forkey:arrairport; tempdic setobject:carrier forkey:carrier; tempdic setobject:code forkey:code; tempdic setobject:codeshare forkey:codeshare; tempdic setobject:fuel forkey:fuel; tempdic setobject:price forkey:price; tempdic setobject:meal forkey:meal; tempdic setobject:plantype f

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论