2013年11月25日 星期一

【職訓局-手機程式開發班】2013 11/25 Android

Flash 轉 Html5
http://www.flash-to-html5.net/

【職訓局-手機程式開發班】2013 11/20 Android

1.物件來回旋轉

1.物件來回旋轉 + 移動

2013年11月21日 星期四

【職訓局-手機程式開發班】2013 11/21 Xcode

錄影檔:

1.http://youtu.be/ESeGDjZxuaQ 介紹xcode系統檔案
1.建立SQLite資料庫
在終端機上輸入:
> sqlite3 account.sqlite

2.將建立的sql檔案拖到xcode專案中*注意下方的add to targets的contacts要打勾

3.下載FMDB 網址https://github.com/ccgus/fmdb

4.將下載好的解壓縮,裡面有個src將他拖到xcode專案中(fmdb.m不用)

5.剛開始時要確定自己建立的資料庫是否複製到app中


6.基本資料庫連線:先import "FMDatabase.h"
在輸入:


FMDatabase *db = [[FMDatabase alloc] initWithPath:[self
                                                      pathForDatabase:@"account.sqlite"]];
[db open]; // 開啓資料庫
[db close]; // 關閉資料庫

7.查詢全部資料

8.新增 (修改刪除都類似)

9.管理工具可用firefox的工具
先安裝好firefox 在下SQLite Manager
安裝好就可以在工具找到SQLite Manager
再按開啓.sqlite檔案就能管理

UIScrollView使用:

1.設定outlet及protocol


@interface ViewController : UIViewController<UIScrollViewDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scrollview;

2.程式部分

- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return scrollView.subviews[0]; // 設定可以縮放的目標
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picas.jpg"]]; // 建立UIImageView 並設定圖片
    [self.scrollview addSubview:imageView]; // imageView 加入scrollview
    self.scrollview.minimumZoomScale = 0.5f; // 設定最大縮小倍率
    self.scrollview.maximumZoomScale = 5.0f; // 設定最大放大倍率
    self.scrollview.contentSize = imageView.bounds.size; // 設定scrollview的範圍
    self.scrollview.delegate = self; // 設定代理者
}

TableView使用:
1.建立tableView:可剛開始就新增也可後來自己拉出tableView

2.設定內容
- (void)viewDidLoad
{
    [super viewDidLoad];
    prices = @[@"NT$350",@"NT$400",@"NT$300",@"NT$250"];
    titles = @[@"book1",@"book2",@"book3",@"book4"];
    UIImageView *imageView1 = [[UIImageView alloc]
                               initWithImage:[UIImage imageNamed:@"footer.png"]]; // 設定標題圖片
    imageView1.contentMode = UIViewContentModeScaleAspectFit; // 讓圖片不會變形
    self.tableView.tableFooterView = imageView1;
   
    UIImageView *imageView2 = [[UIImageView alloc]
                               initWithImage:[UIImage imageNamed:@"header.jpg"]]; // 設定頁尾圖片
    imageView2.contentMode = UIViewContentModeScaleAspectFit; // 讓圖片不會變形
    self.tableView.tableHeaderView = imageView2;
}

3.加入內容
- (UITableViewCell *) tableView:(UITableView *)tableView
          cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString  *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]
                initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
   
    // 加入內容
    cell.imageView.image = [UIImage imageNamed:
                            [NSString stringWithFormat:@"book%d.jpeg",indexPath.row+1]]; // 設定row的圖片
    cell.imageView.contentMode = UIViewContentModeScaleAspectFit; // 讓圖片不變形
    cell.textLabel.text = titles[indexPath.row];  // 將陣列文字放入
    cell.detailTextLabel.text = prices[indexPath.row]; // 將陣列裡價格放入
    return cell;
}