佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 3406|回复: 9

iOS开发教学 - Malaysia Car Plate

[复制链接]
发表于 26-3-2012 10:10 PM | 显示全部楼层 |阅读模式
本帖最后由 sooyewguan 于 28-3-2012 04:09 PM 编辑

最近开发了新的apps, Malaysia Car Plate
http://itunes.apple.com/my/app/malaysia-car-plate/id504558521?ls=1&mt=8

觉得是个很好的学习project,想吧它的制桌过程分享,好让有心趣在ios发展的大大,可以从这得到些概念。

http://blog.bedtime-creations.com/

第一章:开始新的Project







完成品


http://blog.bedtime-creations.com/?p=13

评分

参与人数 1人气 +5 收起 理由
hui_wooi + 5 精品文章

查看全部评分

回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 27-3-2012 01:14 PM | 显示全部楼层
本帖最后由 sooyewguan 于 28-3-2012 04:08 PM 编辑

第二章:UITableView + UINavigationController
> 如何把TableViewController加进NavigationController

打开 AppDelegate.h, 然后跟改想以下的code
  1. @interface AppDelegate : UIResponder <UINavigationControllerDelegate>
  2. {
  3. }
  4. @property (strong, nonatomic) UIWindow *window;
  5. @property (strong, nonatomic) UINavigationController *navigationController;
复制代码
然后在打开 AppDelegate.m 跟改以下的code

  1. @synthesize window = _window;
  2. @synthesize navigationController = _navigationController;

  3. - (void)dealloc
  4. {
  5.     [_window release];
  6.     [_navigationController release];
  7.     [super dealloc];
  8. }

  9. - (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
  10. {
  11.     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  12.     ViewController *viewController1 = [[[ViewController alloc] initWithNibName"ViewController" bundle:nil] autorelease];
  13.     self.navigationController = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease];  
  14.     self.window.rootViewController = self.navigationController;
  15.     [self.window makeKeyAndVisible];
  16.     return YES;
  17. }
复制代码



http://blog.bedtime-creations.com/?p=30
回复

使用道具 举报

 楼主| 发表于 27-3-2012 10:12 PM | 显示全部楼层
本帖最后由 sooyewguan 于 27-3-2012 10:28 PM 编辑

第三章:读取 Data
之前做了一个MySQL Database, 可以通过PHP来读取每天更新的车牌.
http://pjpplate.comze.com/get_cur.php?state=*

各洲的可以从. state是要读取哪个洲, length是要读取多少天.
http://pjpplate.comze.com/get_del.php?state=Melaka&length=30

得到的Data是用JSON的格式. 接下来是要如何把Data放进Apps的TableView.
回复

使用道具 举报

 楼主| 发表于 28-3-2012 03:49 PM | 显示全部楼层
本帖最后由 sooyewguan 于 28-3-2012 04:07 PM 编辑

首先, 下载体iOS的JSON: JSON.zip

然后将它unzip到你project folder.

在XCode里,增加一个新的Group,叫做JSON.


Right click那个JSON Group,然后选着 Add Files to


将刚刚unzip的file,全部add进project里


在 ViewController.h 加以下的code
  1. #import <UIKit/UIKit.h>
  2. @interface ViewController : UIViewController
  3. {
  4.     NSMutableData *responseData;
  5. }
  6. - (void) getData;
  7. @end
复制代码


在ViewController.ms的上面
  1. #import "SBJSON.h"
复制代码


然后在ViewController.m

  1. - (void)viewDidLoad
  2. {
  3.     [super viewDidLoad];
  4.     responseData = [[NSMutableData data] retain];
  5.     [self getData];
  6. }

  7. - (void)viewDidUnload
  8. {
  9.     [super viewDidUnload];
  10.     [responseData dealloc];
  11. }

  12. - (void) getData {   
  13.     NSLog(@"Request new data");
  14.     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://pjpplate.comze.com/get_cur.php?state=*"]];
  15.     (void)[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
  16. }

  17. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
  18.     [responseData setLength:0];
  19. }

  20. - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
  21.     [responseData appendData:data];
  22. }

  23. - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
  24.     NSLog(@"Connection failed: %@", [error description]);
  25. }

  26. - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
  27.     NSLog(@"Done downloading data");

  28.     NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
  29.    
  30.     NSLog(@"%@",responseString);
  31. }
复制代码


完成品。可以从XCode里看到成功下载的data

http://blog.bedtime-creations.com/?p=41
回复

使用道具 举报

发表于 13-4-2012 10:12 AM | 显示全部楼层
很少人会这样share project。
谢谢LZ的用心。
可惜,自己没有iphone和mac机,只能看不能学。
不过还是要顶一下!
回复

使用道具 举报

发表于 23-4-2012 12:00 AM | 显示全部楼层
donwload来玩了,很不错的apps
回复

使用道具 举报

Follow Us
发表于 1-7-2012 04:40 PM | 显示全部楼层
好像很复杂。。。谢谢分享
回复

使用道具 举报

 楼主| 发表于 4-11-2013 10:47 PM | 显示全部楼层
正在测试着Windows Phone 8版的 Malaysia Car Plate。谢谢大家一直以来的自持。





回复

使用道具 举报


ADVERTISEMENT

发表于 13-11-2013 11:43 PM | 显示全部楼层
想问:广告费会多吗??
回复

使用道具 举报

发表于 23-2-2014 10:15 PM | 显示全部楼层
请问如果没macbook 可以制作吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 1-11-2025 04:51 AM , Processed in 0.112880 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表