2015年9月3日 星期四

[iOS]退出App動畫

Objective-C:


        UIWindow *window = [UIApplication sharedApplication].delegate.window;
        [UIView animateWithDuration:1.0f animations:^{
            window.alpha = 0;
            window.frame = CGRectMake(window.bounds.size.width / 2, window.bounds.size.height / 2, 0, 0);
            } completion:^(BOOL finished) {
            exit(0);
        }];

Swift:

        let window:UIWindow = ((UIApplication.sharedApplication().delegate?.window)!)!
        UIView.animateWithDuration(1, animations: {
            window.alpha = 0
            window.frame = CGRectMake(window.bounds.size.width / 2, window.bounds.size.height / 2, 0, 0)
            }, completion: {
                void in exit(0)
        })


reference:http://blog.eyrefree.org/articles/153.html

2015年8月25日 星期二

[iOS]Xcode 6 Disable ARC 設定

Disable ARC 
Build Settings  -> Search Automatic Reference Counting ->  NO


Disable ARC on single files
Build phases -> compile sources double click on the file and enter:
-fno-objc-arc 


2015年5月9日 星期六

[Android]嵌入Admob

step1:註冊AdMob http://www.google.com.tw/ads/admob/
























step2:選擇應用程式




step3:設定廣告樣式


step4:建立新的project

平台 SDK 版本至少為 9,Google Mobile Ads SDK 支援的最低版本

step5:下載Google 儲存庫

step5:設定 build.gradle


step6:修改AndroidManifest.xml

step7:設定廣告單元編號strings.xml




step8:在廣告顯示頁面layout中加入AdView


step9:在Activity.java 中載入廣告



source code:https://github.com/YehHuaChen/AdMob

2014年11月27日 星期四

[Android]Eclipse 快捷鍵

ctrl + / 註解 (取消註解)

ctrl + shift + O 自動匯入所欠缺的類別

alt + ← 移至上一次游標所在位置

alt + → 移至下一次游標所在位置

ctrl + shift + P 移至匹配的括號

ctrl + Q 移至上一次編輯的位置

ctrl + shift + L 列出所有快速鍵

alt + shift + R 修改變數名稱

alt + / 程式碼輔助

ctrl + D 刪除單一行

ctrl + shift + F 程式碼自動排版

ctrl+ L 移至指定行數

ctrl+shift+Y 小寫字母

ctrl+shift+X 大寫字母

ctrl+alt+/ 自動完成

ctrl+3 搜尋在分頁中的檔案

ctrl+shift+U

alt+shift+J 加入Java doc說明

ctrl+* Expand All

ctrl+shift+T search

ctrl+shift+R Open Resource

ctrl+F6 上次使用的檔案

ctrl+alt+H 顯示繼承架構

ctrl+shift+G references in workspace

ctrl+F11 快速執行

F11 快速執行(Debug模式)

ctrl+K 快速搜尋選取的字

ctrl+1 自動修復

[Android]Queue(FIFO)

Reference:
Queue | Android Developments
http://developer.android.com/reference/java/util/Queue.html

http://jhengjyun.blogspot.tw/2010/09/java-queue.html

不要使用原始的add()和remove(),在Queue中會丟出exception,
以offer()和poll()來代替
方法傳回值說明
offer(E o)boolean加入物件
peek()E取得物件,若空傳回null
element()E取得物件,若空傳回例外
poll()E取得物件,並移除該物件,若空傳回null
remove()E取得物件,並移除該物件,若空傳回例外
範例: import java.util.*; 
public class Ex { 
    public static void main(String[] args) { 
        Queue q = new LinkedList(); 
        q.offer("First"); 
        q.offer("Second"); 
        q.offer("Third"); 
        Object o; 
        System.out.println(q.toString()); 
        while((= q.poll()) != null) { 
            String s = (String)o; 
            System.out.println(s); 
        } 
        System.out.println(q.toString()); 
    } 
}

[Android]Eclipse svn:ignore bin and gen

Reference:
Subclipse svn:ignore
http://stackoverflow.com/questions/1066809/subclipse-svnignore

Subversive: Ignore bin/ and gen/ folders
https://www.youtube.com/watch?v=UrQnsFfsaPY

[iOS]退出App動畫

Objective-C:         UIWindow *window = [UIApplication sharedApplication].delegate.window;         [UIView animateWi...