2014年3月10日 星期一

設定App只能安裝於支援Bluetooth low energy的iDevice

隨著愈來愈多結合Bluetooth LE的App應用,一開始就在App裡限定支援的機型,防止沒有Bluetooth LE的舊型裝置誤裝App也就變得十分重要。想要加上防護措施其實很簡單,進入App的Info設定頁面後,於Required device capabilities填入bluetooth-le,即可建立百分百安全的防護罩,包準不支援Bluetooth LE的iPhone 4無法越雷池一步 !


1. 切換至App的Info設定頁面




2. 於Required device capabilities新增bluetooth-le




2014年3月4日 星期二

設定App支援的最低iOS版本

經由Target App General頁面下的Development Target,我們可以設定App支援的最低iOS版本。




由於iOS的高升級率,大部分的時候我們大可只專注於開發支援最新iOS的App。然而人在江湖,身不由己。有些時候老闆還是會希望我們開發出支援老舊iOS版本的App,比方早已過時的iOS 5。但是 ... Xcode 5早已狠心地將iOS 5移除,讓它消失於設定最低支援iOS版本的 Development Target清單。

別擔心,我們永遠都有那最後的絕招,"手動輸入"! 只要親手輸入5.1.1,即可讓App支援iOS 5







2014年3月2日 星期日

App上架前測試清單

1. 熱點分享或電話來電造成status bar變高,覆蓋到App畫面

2. 確認鍵盤的Return Key
    ex:  Return, Done, Next, etc

3. 確認圖片是否沒有維持比例縮放
    一般採用UIViewContentModeScaleAspectFill維持比例

4. 文字輸入是否要預設字首大寫
    預設是字首大寫,可將autocapitalizationType設為UITextAutocapitalizationTypeNone關掉

5. 密碼輸入是否設為看不到的 ...。
    將secureTextEntry設為YES,預設是NO

6. 字串太長時的顯示
    三種方式擇一:
    (1) 結尾 ...
    (2) 文字大小隨字串長度動態調整,當字串愈長時文字愈小
    (3) 分行顯示,例如原本一行顯示改成兩行

 





人非聖賢,孰能無過的常見bug清單

1. 記憶體 (memory)

1-1  memory  leak  
造成記憶體用量增加,最終導致App Crash

1-1-1  剪裁圖片 ( CGImageCreateWithImageInRect )

ex:

UIImage *originalImage = [UIImage imageNamed:@"test.png"];
CGRect cropRect = CGRectMake(0, 0, 320, 320);
CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage], cropRect);
UIImage *cropImage = [UIImage imageWithCGImage:imageRef];
UIImageView *imageView = [[UIImageView alloc] initWithImage:cropImage];

問題:  忘記呼叫CGImageRelease

正確寫法:
UIImage *originalImage = [UIImage imageNamed:@"test.png"];
CGRect cropRect = CGRectMake(0, 0, 320, 320);
CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage], cropRect);
UIImage *cropImage = [UIImage imageWithCGImage:imageRef];
UIImageView *imageView = [[UIImageView alloc] initWithImage:cropImage];
CGImageRelease(imageRef);


2014年1月16日 星期四

在iOS 6,捲動沒有資料的Picker將會Crash



原來,在iOS 6,沒有資料,一無所有的Picker是不能捲動的危險人物呀 !  ( 不過在iOS 7倒是可以安心地捲動,不會crash )

捲動後crash的遺跡如下:

2014-01-16 20:59:20.658 TestPIcker[66169:907] *** Assertion failure in -[UITableViewRowData rectForRow:inSection:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableViewRowData.m:1630
2014-01-16 20:59:20.659 TestPIcker[66169:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect at invalid index path (<NSIndexPath 0x7771400> 2 indexes [0, 0])'

2014年1月2日 星期四

設定Activity Indicator View的顏色

    UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] init];
    activityIndicatorView.color = [UIColor orangeColor];    
    [self.view addSubview:activityIndicatorView];
    [activityIndicatorView startAnimating];
    activityIndicatorView.center = self.view.center;

說明:

利用UIActivityIndicatorView的color property,設定UIActivityIndicatorView物件的顏色