iOS 開發百問(2)

來源:互聯網
上載者:User

11、無法調試裝置“Error launching remote program: failed to get the task forprocess 6405.”

ad-hoc Profile不支援調試。改為development profile。

12、OTA無法下載,提示“無法下載應用程式”

.plist檔案中的 bundle-identifier寫錯了(或者包含中文字元),比如:

bundle-identifier

com.xxx.--APN--

其中的com.xxx.—APN—中包含中文(“--”),應改為英文。

或者簽署憑證是無效的。請在Orgnizer中檢測簽署憑證。

12、ASIHTTPRequest中經常出現EXEC_BAD

使用ASIHTTPRequest進行非同步請求時,經常出現程式崩潰。尤其在是請求過程中(未Finished),如果你切換了視圖的時候。因為是非同步請求,request對象可能在任何時候調用delegate(ViewController),而此時ViewController卻可能已經釋放了。因為UIKit隨時會釋放當前不顯示的ViewController。如果你切換了ViewController,那麼那個被隱藏的ViewController隨時會被釋放。如果request回調ViewController的delegate方法時,而那個ViewController正好被UIKit給釋放,則會導致EXEC_BAD。在官方文檔中也提到:Requests don’t retain their delegates, so if there’s a chance your delegatemay be deallocated while your request is running, it is vital that you clearthe request’s delegate properties. In most circumstances, if your delegate isgoing to be deallocated, you probably also want to cancel request, since you nolonger care about the request’s status

因此在使用ASIHTTPRequest進行非同步編程時,我們要自己清空request的delegate屬性。在delegate(ViewController)的dealloc方法中你應該: 
[request clearDelegatesAndCancel];[request release];

當然,request不能是臨時變數,而應當是一個retained的成員對象(或者屬性),否則你無法在dealloc方法中clearDelegatesAndCancel。

13、Assertion failure in -[UIActionSheet showInView:]

在主線程中開啟action sheet:

[selfperformSelectorOnMainThread:@selector(showActionSheet) withObject:nilwaitUntilDone:NO];

showActionSheet方法:

-(void) showActionSheet

{ sheet = [[UIActionSheet alloc] initWithTitle:@"This is my ActionSheet!" delegate:self cancelButtonTitle:@"OK"destructiveButtonTitle:@"Delete Message!" otherButtonTitles:@"Option1", @"Option 2", @"Option 3", nil];

[sheet showInView:self.view];

}

14、RegexKitLite編譯錯誤

編譯時間提示如下錯誤:

"_uregex_find", referenced from: _rkl_search in RegexKitLite.o

……

在Build Settgins的Other Linke Flag中加入

-licucore

15、Archive時遇到“ResourceRules.plist:cannot read resources”錯誤

在build settings中找到Code Signing Resource Rules Path,填入$(SDKROOT)/ResourceRules.plist

16、使用ZombieEnable解決EXEC_BAD_EXCESS錯誤

這個錯誤是向一個release對象發送訊息導致的。可以通過開啟ZombieEnable參數來尋找真正的問題。

Edit Scheme,選擇Run …Debug,開啟Arguments組,在Environment Variables中添加一個參數:

運行程式,當出現EXEC_BAD_EXCESS錯誤時,控制台中會輸出具體出錯的資訊,比如:

*** -[ITSMTicketCell release]: message sent to deallocated instance0x897e920

直接指明了是由於某個對象在被釋放之後,你發送了一條訊息給它。

17、 關於Xcode4無法調試2代代老裝置的問題

升級到Xcode4以後,你會發現許多程式無法在2代裝置(有些3代裝置,比如iTouch 3實際上仍然是2代的硬體)上運行了,並且Xcode4僅僅“Running…”就直接“Finished…”了,無論是Xcode控制台還是裝置日誌中,都沒有任何提示。

注意:2代和3代的區別在於cpu架構。2代裝置使用ARMv6架構cpu,3代裝置使用ARMv7架構cpu。 iPhone 2G/3G,iPod 1G/2G屬於ARMv6架構(2代),iPhone3GS/4, iPod 3G,iPad屬於ARMv7架構(3代)。

stackoverflow上有關於這個的文章,其中shapecatcher的答案是最準確的:

http://stackoverflow.com/questions/6378228/switching-from-xcode3-to-xcode4-cant-load-programs-onto-older-ipod-touch

1、開啟Target的Build Settings,找到Architectures選項,將其從“$(ARCHS_STANDARD_32_BIT)”修改為“armv6$(ARCHS_STANDARD_32_BIT)”。注意大小寫是敏感的。“$(ARCHS_STANDARD_32_BIT)”是一個變數,實際上等同於armv7。

2、Base SDK不需要改變,仍然是Lastest iOS。

3、開啟Target的info,找到Required device capabilities,將下面的armv7刪除。這個選項是Xcode4自己添加在工程中的預設設定,如果不去掉它,第1步-第2步的工作是無法生效的。

18、“Avalid provisioning profile for this device was not found.”

在你的開發認證中增加該裝置的UDID。

19、將裝置添加到 portal

串連裝置,開啟Orgnizer。在裝置列表中選中裝置,點擊右邊視窗左下角的“Add to Portal”按鈕。或者在裝置列的裝置上右擊,選擇“AddDevice to Provisioning Portal”。

20、renew profile

開啟Orgnizer,在LIBRARY中選擇Provisioning Profiles。在右邊視窗選擇要renew的profile,點擊右下角的“Refresh”按鈕。輸入Portal的密碼,profile將被renew。

21、renew簽署憑證及裝置啟用文檔

從portal移除到期的簽署憑證重新製作開發認證和發布認證刪除開發和部署所用的啟用文檔(provisioningprofiles)使用新的認證重新製作用於開發和部署的Provisioningprofiles從鑰匙串中刪除老的認證在XcodeOrganizer中安裝新的provisioning profiles完成

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.