基于LBS的iOS客户端应用之生活助手毕业论文设计,程序源代码,ppt,开题,翻译

3995
    


来源:
Licence:
联系:
分类:
平台:
环境:
大小:
更新:
标签:
联系方式 :
免费下载 ×

下载APP,支持永久资源免费下载

限免产品服务请联系qq:1585269081

下载APP
免费下载 ×

下载APP,支持永久资源免费下载

下载APP 免费下载
下载 ×

下载APP,资源永久免费


如果出现不能下载的情况,请联系站长,联系方式在下方。

免费下载 ×

下载论文助手APP,资源永久免费

免费获取

如果你已经登录仍然出现不能下载的情况,请【点击刷新】本页面或者联系站长



简介


摘  要
随着近年来智能手机的爆炸性增长,LBS已经开始广泛被使用并在改变我们的生活:下班后的朋友聚会,可以用大众点评网搜索附近500米内最好吃的餐馆;用Google地图寻找最快捷的路线和抵达方式;发一条新微博,顺手添上自己所在的位置;高德导航可以轻松取代车载GPS,指引下一个聚会地。
本论文主要围绕实现iOS设备的LBS进行相关详细的分析介绍。最终实现附近、搜索、签到、优惠券、今日团购、排行榜、记录、城市信息、更多九大功能模块。
关键词:智能手机、LBS、签到、分享。 


ABSTRACT
In recent years, with the rapid growth of smart phones, the LBS has been widely used and is changing our lives: the gathering of friends after work, you can use the best food restaurant within 500 meters near the public comment network search; use Google Maps to find the most efficientroute and arrival; Post a new microblogging and add their location in it; high De navigation can easily replace the car GPS, under the guidance of a party.
This thesis is mainly around the LBS iOS devices to carry out a detailed analysis of introduction. And ultimately to achieve near, search, sign, coupons, buy, list, record, urban, more these nine functional modules.

Keywords: Smartphone、LBS 、sign in、share.

工程目录

目录
摘  要	I
ABSTRACT	II
目 录		III
第一章	引言	1
1.1 课题的目的和意义	1
1.2移动互联网时代的新宠:LBS应用	1
1.3主要设计内容	2
第二章	iOS、语言、环境以及所用技术介绍	3
2.1 iOS简介	3
2.2 Objective-C语言	4
2.3 Xcode开发环境	4
2.4 SQLite数据库	5
2.5 JSON解析	5
第三章	需求分析	7
3.1 设计背景	7
3.2总体设计	7
第四章	详细设计与实现	9
4.1首页展示设计	9
4.2附近模块设计	10
4.3搜索模块设计	13
4.4签到模块设计	14
4.5优惠券模块设计	16
4.6今日团购模块设计	18
4.7排行榜模块设计	19
4.8记录模块设计	26
4.9城市信息模块设计	28
4.10更多模块设计	29
第五章 测试	30
5.1测试项目	30
5.1.1附近模块测试	30
5.1.2附近模块测试	30
5.1.3签到模块测试	30
5.1.4优惠券模块测试	30
5.1.5今日团购模块测试	30
5.1.6排行榜模块测试	30
5.1.7记录模块测试	30
5.1.8城市信息模块测试	31
5.1.8更多模块测试	31
第六章 参考文献	32
第七章  致谢	33
 

根据需求分析,划分了九大功能模块,其中Neaby,List In Order,Coupons是本软件的特色及关键部分,具体功能如下所示:

首页展示设计

下图4-1为首页界面,最上方用一个UIButton显示城市信息,程序运行时判断当前有无已选城市,第一次运行时判断无已选城市,会跳到城市选择界面(图4-2)。向下紧接着是一个UISearchBar,触碰此searchBar会进入搜索界面。下方显示红色图片的是UIScrollView,其上是九个UIButton,设置各button的背景图片即为所展现之场景,点击各个button会进入个相应界面。


图4-1首页视图

以下代码为通过数据库判断是否已选择城市:

- (void)viewDidAppear:(BOOL)animated

{

MySqlite *mysql = [[MySqlite alloc] init];

if (flag > 0)

{

flag --;

}

if ([mysql getCity]==nil)

{

ChangeCity *city = [[ChangeCity alloc] init];

[self.navigationController pushViewController:city animated:YES];

[city release];

}

else

{

NSString *cityString = [NSString stringWithFormat:@"SPTK Dir.  %@", [mysql getCity]];

UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];

b.tag = 13;

b.frame = CGRectMake(29, 6, 262, 33);

[b setTitle:cityString forState:UIControlStateNormal];

[b setImage:[UIImage imageNamed:@"head1"] forState:UIControlStateNormal];

[b setImageEdgeInsets:UIEdgeInsetsMake(0, 205, 0, 0)];

[b setTitleEdgeInsets:UIEdgeInsetsMake(0, -50, 0, 0)];

[b addTarget:self action:@selector(qwer:) forControlEvents:UIControlEventTouchUpInside];

b.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];

self.navigationItem.titleView = b;

}

[mysql release];


}

4.2附近模块设计

如下图4-2为附近界面,用一个UITableView列表显示信息。

在viewController中设置此tableView的delegate和dataSource为self。在viewController声明文件中遵循UITableViewDelegate和UITableViewDataSource协议,在实现文件中实现UITableViewDelegate和UITableViewDataSource的相应方法:主- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section,- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath。

图4-2附近界面

代码如下:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return [[ListData objectAtIndex:0] count];

}

上面的方法中return的数据为一个section的行数。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)

{

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

cell.textLabel.text = [[ListData objectAtIndex:0] objectAtIndex:indexPath.row];

cell.textLabel.font = [UIFont boldSystemFontOfSize:14];

cell.imageView.image = [UIImage imageNamed:[[ListData objectAtIndex:1] objectAtIndex:indexPath.row]];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}

上面的方法中是实现cell的具体代码。


点击各cell时,调用- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;方法,进入相应界面代码如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

if (indexPath.row == 0)

{

SearchCoupon *tabView = [[SearchCoupon alloc] init];

TKSPAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

[appDelegate.navigationController pushViewController:tabView animated:YES];

[tabView release];

}

else if ([[[ListData objectAtIndex:0] objectAtIndex:indexPath.row] isEqualToString:@"More classification"])

{

MoreCategoriesTable *nextView = [[MoreCategoriesTable alloc] init];

nextView.title = @"More classification";

[self.navigationController pushViewController:nextView animated:YES];

[nextView release];

}

else

{

NearbyOther *nextView = [[NearbyOther alloc] init];

nextView.flag = 0;

nextView.lat = lats;

nextView.lon = lons;

nextView.string = [[ListData objectAtIndex:0] objectAtIndex:indexPath.row];

nextView.title = [[ListData objectAtIndex:0] objectAtIndex:indexPath.row];

[self.navigationController pushViewController:nextView animated:YES];

[nextView release];

}

}

4.3搜索模块设计

如图4-3为搜索界面:


在表格的上方是一个searchBar,设置此表格的headerView为此searchBar,可以实现此searchBar随着table上下拖动。触碰上方的searchBar后触发- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;方法,代码如下:

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText

{

if ([NearbyLogicControl connectedToNetwork])

{

NearbyLogicControl *logic = [[NearbyLogicControl alloc] init];

searchData.listData = [logic getSearchDetail:searchText];

[logic release];

self.searchDisplayController.searchResultsDataSource = searchData;

self.searchDisplayController.searchResultsDelegate = searchData;

}

}

上述代码中:首先判断是否连接网络:[NearbyLogicControl connectedToNetwork],若值为yes,则根据输入的字符串进行搜索并显示。显示时,要设置searchDisplayController的searchResultsDataSource和searchResultsDelegate的值为searchData。

搜索结果如图4-4显示:

 

图4-4搜索结果界面

4.4签到模块设计

如图4-5为签到界面:

由于页面较多采用UITabBarController,将各个viewController添加到一个数组,再设置UITabBarController的viewControllers为此数组即可。当需要组织或组合多个不同领域的功能时,就可以使用UITabBarController。每个功能领域有自己的图标按钮,并且只有用户单击它时才激活。通过setTitle设置每个功能图标的名称,setImage设置图片。

图4-5签到界面

实现代码如下:

- (id)init

{

self = [super initWithNibName:nil bundle:nil];

if (self)

{


self.title = @"Check-in";       

Activity * SecondTabView = [[Activity alloc] init];

[SecondTabView.tabBarItem setTitle:@"Activities"];

[SecondTabView.tabBarItem setImage:[UIImage imageNamed:@"a2"]];


UIViewController *ThirdTabView;

MySqlite *mysql = [[MySqlite alloc] init];

if ([mysql getUser])

{

ThirdTabView = [[MySettings alloc] init];

}else

{

ThirdTabView = [[WhatCheckIn alloc] init];

}

[ThirdTabView.tabBarItem setTitle:@"Me"];

[ThirdTabView.tabBarItem setImage:[UIImage imageNamed:@"d2"]];

[mysql release];


SignToMe * FourthTabView = [[SignToMe alloc] init];

[FourthTabView.tabBarItem setTitle:@"I want to check-in"];

[FourthTabView.tabBarItem setImage:[UIImage imageNamed:@"签.png"]];


SignNear *FirstTabView = [[SignNear alloc] init];

[FirstTabView.tabBarItem setTitle:@"Close Check-in"];

[FirstTabView.tabBarItem setImage:[UIImage imageNamed:@"c2"]];


self.viewControllers = [NSArray arrayWithObjects:FirstTabView, SecondTabView, ThirdTabView, FourthTabView, nil];


[FirstTabView release];

[SecondTabView release];

[ThirdTabView release];

[FourthTabView release];

}


return self;

}

4.5优惠券模块设计

在此模块显示正在进行的优惠商户信息,由于页面较多仍然使用UITabBarController以展示更多信息,每个页面都有一个UITabelView,其上放置一个searchBar,以实现搜索功能。界面如图4-6所示:

图4-6优惠券界面

初始化UITabBarController代码如下:

- (id)init

{

self = [super initWithNibName:nil bundle:nil];

if (self)

{

self.title = @"Coupons";


NearbyDetail *FirstTabView = [[NearbyDetail alloc] init];

[FirstTabView.tabBarItem setTitle:@"Last coupons"];

[FirstTabView.tabBarItem setImage:[UIImage imageNamed:@"c2"]];

NearbyHot * ThirdTabView = [[NearbyHot alloc] init];

[ThirdTabView.tabBarItem setTitle:@"New Coupons"];

[ThirdTabView.tabBarItem setImage:[UIImage imageNamed:@"f2"]];


NearbyHot * FourthTabView = [[NearbyHot alloc] init];

[FourthTabView.tabBarItem setTitle:@"Hot Coupons"];

[FourthTabView.tabBarItem setImage:[UIImage imageNamed:@"e2"]];

NearbySearch *SecondTabView = [[NearbySearch alloc] init];

[SecondTabView.tabBarItem setTitle:@"Search Coupons"];

[SecondTabView.tabBarItem setImage:[UIImage imageNamed:@"h2"]];

self.viewControllers = [NSArray arrayWithObjects:FirstTabView, SecondTabView, ThirdTabView, FourthTabView, nil];

[FirstTabView release];

[SecondTabView release];

[ThirdTabView release];

[FourthTabView release];

//NSLog(@"%d", [FirstTabView retainCount]);

}

return self;

}

4.6今日团购模块设计

如图4-7为今日团购界面:

图4-7今日团购界面

其中中间展示信息的部分用的是UIWebView,正如它的名字,它是用于展示网站的,在此展示网站的团购优惠信息。首先,利用网址字符串构造一个NSURL对象,再由此NSURL对象构造一个NSURLRequest对象,最后通过UIWebView的loadRequest方法就得以展示网站信息了,具体实现代码如下:

- (void)viewDidLoad

{

[super viewDidLoad];

self.title = @"Snap up shopping";

NSString *string = @"http://www.thukhashwepyi.com/tuan/wap/index.php";

//    NSString *string = @"http://192.168.1.106/dp/tuan/wap/index.php";

NSURL *url = [NSURL URLWithString:string];


NSURLRequest *request = [NSURLRequest requestWithURL:url];

[webGoup loadRequest:request];

[string release];

//[request release];

}

4.7排行榜模块设计

此模块是根据人气、评分等展示热门商户和最佳商户的排行的,效果如图4-8:

图4-8排行榜界面

触碰cell后触发- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;函数,代码如下:

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

ListDetail *listView = [[ListDetail alloc] init];

[listView initWithTitleLable:[[listData objectAtIndex:0] objectAtIndex:indexPath.row]];

[self.navigationController pushViewController:listView animated:YES];

[listView release];

}

进入各分类排行,以Most popular Food为例,如图4-9Most popular Food界面:

图4-9Most popular Food界面

进入界面后,从网络加载数据,下载图片,下载图片时,用UIActivityIndicatorView展示旋转等待状态,利用NSData的dataWithContentsOfURL方法实现下载,下载完成后,等待状态要消除,利用UIActivityIndicatorView的stopAnimating方法实现。

代码如下:

- (void)downPicture:(UIImageView *)iv

{

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[ListData objectAtIndex:iv.tag] photo]]]];

iv.image = image;

[((UIActivityIndicatorView *)[iv viewWithTag:21]) stopAnimating];

[pool drain];

}

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{

return [ListData count];

}

不难发现,此tableView的高度明显要高,自定义高度只需在

(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;方法中return你需要的高度,不实现此函数,则表示高度为默认值44,代码如下:

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

return 90;

}

触碰各cell后,触发- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;函数,在此函数中要先实例化下一界面,然后进入这一界面,代码如下:

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

BusinessDetail *businessView = [[BusinessDetail alloc] initWithSid:[[ListData objectAtIndex:indexPath.row] busniessID]];

TKSPAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

[appDelegate.navigationController pushViewController:businessView animated:YES];

[businessView release];

}

签到界面如图4-10:

图4-10签到界面

触碰check-in now按钮后,先判断用户是否登录,若登录则进入checkView界面,若用户没有登录则利用UIAlertView提示用户登录,代码如下:

- (IBAction)CheckIn:(id)sender {

MySqlite *mysql = [[MySqlite alloc] init];

if ([mysql getUser])

{

CheckInPage *checkView = [[CheckInPage alloc] init];

checkView.myId = [mysql getUser];

checkView.businessId = sid;

[self presentModalViewController:checkView animated:YES];

[checkView release];

}else

{

flag = 1;

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Prompted" message:@"Please login first" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Login", nil];

[alert show];

[alert release];

}

[mysql release];

}

若用户已登录则直接进入checkView界面,如下图4-11所示:


图4-11 签到评论界面

在此页面用户可以在textView中输入评论信息,触碰Add photo按钮时弹出一actionSheet,提示用户是通过照相还是从照片库中选取图片来实现插入图片或取消插入功能,另外,需要说明的是选取无论是选取图片还是照相都是通过照片选取器UIImagePickerController来实现的,具体代码如下:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

NSLog(@"%d", buttonIndex);

if (buttonIndex == 0) {

UIImagePickerController *imageView = [[UIImagePickerController alloc] init];

imageView.sourceType = UIImagePickerControllerCameraDeviceFront;

imageView.delegate = self;

[self presentModalViewController:imageView animated:YES];

[imageView release];

}else if (buttonIndex == 1) {

UIImagePickerController *imageView = [[UIImagePickerController alloc] init];

imageView.delegate = self;

[self presentModalViewController:imageView animated:YES];

[imageView release];

}

}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo

{

[picker dismissModalViewControllerAnimated:YES];

[imageButton setImage:image forState:UIControlStateNormal];

}

评论完,触碰submit按钮完成提交签到,首先检查网络是否联通,联通情况下完成提交,若提交成功,通过UIAlertView提示提交成功,具体代码如下:

- (IBAction)submitCheckInfo:(id)sender

{

//提交签到信息接口

if ([NearbyLogicControl connectedToNetwork]) {

NearbyLogicControl *logic = [[NearbyLogicControl alloc] init];

CGSize itemSize = CGSizeMake(80, 100);

UIGraphicsBeginImageContext(itemSize);

CGRect imageRect = CGRectMake(0, 0, 80, 100);

[imageButton.imageView.image drawInRect:imageRect];

imageButton.imageView.image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

NSData *imageData = UIImagePNGRepresentation(imageButton.imageView.image);

//NSString *string = [[NSString alloc] initWithData:imageData encoding:NSASCIIStringEncoding];

if ([logic submitCheck:businessId Checks:textView.text Picture:nil MyId:myId Pdata:imageData]) {

UIAlertView *alertv = [[UIAlertView alloc] initWithTitle:@"Prompted" message:@"Congratulations! , Credit +4" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

[alertv show];

[alertv release];

}else {

UIAlertView *alertv = [[UIAlertView alloc] initWithTitle:@"Prompted" message:@"Check-in failed,Max. four times allowed for this business" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

[alertv show];

[alertv release];

}

[logic release];

}else {

UIAlertView *alertv = [[UIAlertView alloc] initWithTitle:@"Prompted" message:@"Connect faild" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

[alertv show];

[alertv release];

}

}

4.8记录模块设计

在此模块,用户浏览的商户信息浏览记录在此展示,用户在进入商户浏览商户信息前,先将商户信息存储到本地数据库,再通过读取数据库信息,查看浏览记录,界面效果如图4-12:


图4-12浏览记录界面

界面实现代码如下:

- (void)viewDidLoad

{

[super viewDidLoad];

self.title = @"Recently Viewed";

tableList.delegate = self;

tableList.dataSource = self;

MySqlite *sqlite = [[MySqlite alloc] init];

ListData = [sqlite getBusiness];

[sqlite release];

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Clear" style:UIBarButtonItemStyleBordered target:self action:@selector(Clear:)];

self.navigationItem.rightBarButtonItem = item;

}

将商户信息存储到本地数据库,代码如下:

- (BOOL)SaveBusinessInfo:(BusinessInfo *)shop

{

NSString *sql = [NSString stringWithFormat:@"INSERT INTO BusinessList (sid,sn,score,cost,address,purl,subname,tag) VALUES('%@','%@','%@','%@','%@','%@','%@','%@');", shop.busniessID, shop.businessName, shop.score, shop.cost, shop.Address, shop.photo, shop.businessTitle2, shop.Tag];


//    NSLog(@"SQL == %@", sql);

int status = sqlite3_exec(database, [sql UTF8String], 0, 0, NULL);

//   NSLog(@"SQL == %d", status);

return status;

}

触碰Clear实现清空记录,通过删除数据库数据实现,代码如下:

- (void)Clear:(id)sender

{

MySqlite *sqlite = [[MySqlite alloc] init];

[sqlite opendatabase];

[sqlite deleteTempBusiness];

ListData = [sqlite getBusiness];

[tableList reloadData];

[sqlite close];

[sqlite release];

}


4.9城市信息模块设计

在此模块,展示该城市的公共服务信息,如医院,警察局等,还是通过UITableView显示,界面如图4-13:

图4-13城市信息界面

实现代码如下:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return 13;

}

上面返回的是cell的个数。


再调用- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath实现各个cell。

4.10更多模块设计

此模块主要实现用户登陆,城市选择,建议反馈,帮助,关于功能,在此主要介绍一下用户登陆,因为其他功能在前面所述中均已涉及,不做过多赘述。界面效果如图4-14:  

图4-14更多界面

判断是否已登录的代码如下:

cell.textLabel.text = @"Account settings";

MySqlite *mysql = [[MySqlite alloc] init];

if ([mysql getUser]!=nil) {

cell.detailTextLabel.text = [mysql getUser];

}else {

cell.detailTextLabel.text = @"Please sign in";

}


[mysql release]; }


免费下载 ×

下载APP,支持永久资源免费下载

下载APP 免费下载
温馨提示
请用电脑打开本网页,即可以免费获取你想要的了。
扫描加我微信 ×

演示

×
登录 ×


下载 ×
论文助手网
论文助手,最开放的学术期刊平台
				目录
摘  要	I
ABSTRACT	II
目 录		III
第一章	引言	1
1.1 课题的目的和意义	1
1.2移动互联网时代的新宠:LBS应用	1
1.3主要设计内容	2
第二章	iOS、语言、环境以及所用技术介绍	3
2.1 iOS简介	3
2.2 Objective-C语言	4
2.3 Xcode开发环境	4
2.4 SQLite数据库	5
2.5 JSON解析	5
第三章	需求分析	7
3.1 设计背景	7
3.2总体设计	7
第四章	详细设计与实现	9
4.1首页展示设计	9
4.2附近模块设计	10
4.3搜索模块设计	13
4.4签到模块设计	14
4.5优惠券模块设计	16
4.6今日团购模块设计	18
4.7排行榜模块设计	19
4.8记录模块设计	26
4.9城市信息模块设计	28
4.10更多模块设计	29
第五章 测试	30
5.1测试项目	30
5.1.1附近模块测试	30
5.1.2附近模块测试	30
5.1.3签到模块测试	30
5.1.4优惠券模块测试	30
5.1.5今日团购模块测试	30
5.1.6排行榜模块测试	30
5.1.7记录模块测试	30
5.1.8城市信息模块测试	31
5.1.8更多模块测试	31
第六章 参考文献	32
第七章  致谢	33
			 
回复
来来来,吐槽点啥吧

作者联系方式

×

向作者索要->