2011年2月22日 星期二

iPhone 發佈時遇到的小小warning

在我distribution的時候有遇到這麼個小小warning

warning: 'The Validate Built Product build setting was not enabled when building for Distribution.'

這是個滿貼心的warning,因為有了Validate Built Product這個檢查,
會初步幫忙開發者找到問題,避免在submit時發生問題.

參考網站有詳細的圖文介紹
我這裡僅以文字描述:P
1. 在xcode裡開啟project的內容(Get Info)
2. 切換到build tag
3. 搜尋Validate Built Product
4. checkbox確定要打勾勾

呵~勾完重新執行的結果,馬上就有icon的問題...

iPhone 發佈時遇到的 icon problem

這是我在作distribution時遇到的其中一個問題
Icon specified in the Info.plist not found under the top level app wrapper:
icon.png (-19007)

網路上滿多解答的,我參考了coco2d for iPhone上的討論

1. 首先將info.plist的Icon files欄位修改成CFBundleIconFiles
2. 然後新增 (名稱大小寫都照著取,即使是iPad project也一樣)
    Icon.png
    Icon@2x.png
    Icon-72.png
    Icon-Small.png
    Icon-Small-50.png
    Icon-Small@2x.png
3. 重新將project的resource file刪除再加入,以確保project有最新的icon

最後,還可以參考一下官網的guide
像57x57 pixels is for iPhone/iPod
114x114 pixels is for high resolution iPhone/iPod
72x72 pixels is for iPad
(我想以後可能還要提供72@2x的icon吧~)

2010年12月31日 星期五

iPhone error滿天飛 debug來跨年

有時error往往會在最關鍵的時候冒出來
(譬如說:我想過Christmas,我想去跨年...但是有些bug還沒解)
尤其是一些系統上的問題或是鬼打牆的小細節

首先登場的是
"No provisioned iPhone OS device is connected"

明明就接好好的device,你跟我說沒有provision
要解決這奇怪的現象,
可以試試在Organizer把provisioning裡的files通通delete讓他重裝

接著登場的是
"The program being debugged is not being run"

很無厘頭的error,但是解法跟上面的症狀是一樣的
進入Organizer把provisioning profiles清一清
還不行的話,從apple developer重新下載吧

最後登場的是
"CFPropertyListCreateFromXMLData(): 
Old-style plist parser: missing semicolon in dictionary."

話說在我要提供多國語言需求下,建立了lproj的strings file
奇怪的是出了這個error還跟我說 Unexpected character at line 1
第一行很ok阿,哪有什麼問題!也有semicolon阿
然而在我浪費了約1個小時的青春尋找問題
最後....在文件的很後面 很後面 的某一行.....真的少了一個semicolon...@#$%
所以at line 1是騙人的,semicolon是一定有漏掉的地方
睜大眼睛快找找吧~

Happy New Year & Happy Debugging  lol

2010年12月22日 星期三

iPhone 我後悔了~ performSelector 停下來阿

雖然短的跟一行文沒什麼兩樣
但是之前沒記下來,那就開個版面寫一下

Tips:
故事是這樣發生的...
下面的動作是在touch event觸發之後會去執行的
[self performSelector:@selector(myFunc) 

           withObject:nil 

           afterDelay:delay];

但是,在這個延遲的期間又去觸發touch event...
已經下達的performSelector是不會理會的
使用者可能會有UI行為不一致的感覺

因此,在下達performSelector若能把前一次 未執行完的動作給停掉
會是比較理想的作法,cancel 方法如下:
[NSObject cancelPreviousPerformRequestsWithTarget:self

                                       selector:@selector(hideMsg)

                                           object:nil];


參考來源: stackoverflow
                iphonedevsdk

2010年12月13日 星期一

iPhone 更改專案名稱 (update:完整版)

剛起始一個專案的時候
我有個很糟糕的習慣就是取了爛名字
什麼xxxtest阿,xxxdemo等等...
等真的要release的時候不免被人家念一頓

其實要修改 project name也不難
1. 找到專案的info.plist
2. 找到"Bundle display name"的欄位
3. 將原本 ${PRODUCT_NAME} 改成想要的名稱

如果遇到
the program being debugged is not being run
的error message也不要慌,
shift + command + K 把專案給clean重編就好了

參考資料:stackoverflow
              iphonedevsdk

update: 2011/05/10
嗯~原本的作法算是治標不治本
如果精明一點可以發現透過organizer看到的device log都還是舊名稱
雖然之前就有看到網路上有教學
不過好害怕整個project改爛了就很好笑了

anyway,凡是總有第一次,先備份起來總不會失控吧!
更改專案名稱真的沒有這麼恐怖,給我5分鐘就可以搞定的:)

Let's change the project name completely
1. Copy all files under old project directory to a new one.
    拷貝所有舊專案資料夾底下的file到新的資料夾


2. Rename "old_name.xcodeproj" to "new_name.xcodeproj" then open it.
    將舊的xcodeproj檔名改成想要的新名稱,然後用xcode打開


3. Check if project with the new name under Group&Files pane and Target pane
    修改並確定project name及Targets的名稱是新的


4. Clean the project by shift+command+K and quit xcode that's it, 
    don't rename any other file name at this state.
    清除專案,別急著將其他檔案更名,拜託,我在這步失敗過:P


5. Right click on the "new_name.xcodeproj" and choose "show package content",
    open "project.pbxproj" by xcode.
    回到資料夾在xcodeproj檔案上面按右鍵 選顯示套件內容 打開project.pbxproj


6. Replace all "old_name" with "new_name" save and quit
    用new_name取代所有的old_name, 儲存後離開


7. Open the project again, and rename "old_name" to "new_name" in entire project,
    the red lost referenced files should disappear.
    再次開啟xcode將 project中出現的所有"old_name"用"new_name"取代


8. Open "new_nameViewController.xib" and "MainWindow.xib" to correct the class
     identity.
    開啟"new_nameViewController.xib"與"MainWindow.xib"更改delegate, controller的
    class identity欄位


9. 重新編譯,完成!!

我的作法並無使用console,希望對大家有幫助

參考資料:WebObject blog

iPhone POST url遇上跳脫字元的處理方式

寫過網路程式的人都知道
POST url之前最好要將內容encode過
不然decode過程中一定會有判讀錯誤的問題
ex: user=123&abc&pass=qwe=asd
encode後送出 user=123%26abc&pass=qwe%3Dasd
原本以為下面的encoding method用得好好的
沒想到是一個大bug

[unencodedObj stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


所以請大家改用

(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
                                 (CFStringRef)unencodedObj,
                                                    NULL,
                             CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                          kCFStringEncodingUTF8 );


參考來源: simonwoodside
                iphonedevsdk

2010年11月23日 星期二

iPhone UIImage的圓角效果及橫向splash screen

原本以為這兩件事情是有難度的,
還好是自己嚇自己~
參考看看囉:)

UIImage圓角效果
1. 找到左側列表的Frameworks,右鍵加入existing frameworks
QuartzCore.framework

2. 記得在.m的檔案也加入
#import

3. 設定圖片來源的同時也設定圓角效果的屬性
imageView.layer.cornerRadius = 5.0;
imageView.layer.masksToBounds = YES;

//And to add a border:
imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
imageView.layer.borderWidth = 1.0;
imageView.image = [UIImage imageNamed:@"image.png"];

比較一下有無圓角的效果吧~

載入橫向的splash screen
根據網路上的結論是…辦不到!!
ㄜ~程式上是辦不到,不過圖片可以動手腳
iPhone的Default.png請轉90度,變成320x480
iPad的Default.png請轉90度,變成768x1024


資料來源:
           iPhoneSDKPro
           iphonedevsdk

內容回應