iOS 開發百問(3)

來源:互聯網
上載者:User

22、解決 messagesent to deallocated instance 0x52cc690 錯誤

當試圖對某個對象進行賦值操作的時候出現這個錯誤,如:

tfContent.text=bodyText;

此時,你可以開啟NSZombieEnable選項,則console會有如下輸出:

***-[CFString _isNaturallyRTL]: message sent to deallocated instance 0x52cc690

說明_isNaturallyRTL訊息被發送給了一個已經釋放了的對象。從上面的語句看,可能是這兩個對象:tfContent、bodyText。

你可以列印tfContent或者bodyText的記憶體位址,看看到底是哪個對象已經被釋放掉了:

NSLog(@"tfContent:0x%x",(int) tfContent);

NSLog(@"bodytext:0x%x",(int) bodyText);

結果表明是bodyText被提前釋放:

tfContent: 0x52cf160

bodytext: 0x52cc690

在適當的地方對bodyText進行retain,問題解決。

23、 putpkt:write failed: Broken pipe錯誤

重啟裝置。

24、.hfile not found

實際上該.h檔案並沒有被包含進target。選擇對應.m檔案,點擊“ShowUtilities”按鈕(在工具條的右端),在Utilities中找到Target Membership,將Target前面的勾去掉,然後再重新勾上。即相當於將該.m檔案重新加入target的Buildphase中。

25、 Xcode 4:如何將for iPhone的xib轉變為for iPad

在Xcode 3.x中,將xib從iPhone版轉變為iPad版,通過Create iPad Version菜單。

但在Xcode 4.x中,這個菜單找不到了。通過一番摸索,筆者發現可以用如下方法將xib轉換為iPad版本。

1、修改xib源檔案

xib檔案其實是一個xml檔案。在Project Navigator中,在xib檔案上右鍵,選擇“Open As -> Source Code”,即可以原始碼方式查看xib檔案,找到"com.apple.InterfaceBuilder3.CocoaTouch.XIB"一行,將其改為 "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB",即增加了".iPad"。

按下?+F,開啟搜尋欄,點擊Replace菜單,將模式改變替換模式。將xib檔案中所有"IBCocoaTouchFramework"用 "IBIPadFramework"替換。

按下?+S,儲存修改。

2、修改xib的視圖尺寸

在xib檔案上右鍵,選擇“Open As -> Interface Builder – iOS”,用IB模式開啟。

選擇xib檔案中的根視圖(UIView),在屬性面板中找到Size選項,將其改為Full iPad Screen。

現在,你可以有一個iPad版本的xib了。

26、icon dimensions (0 x 0) don't meet the size requirements.

開啟Project的BuildSettings,找到Compress PNG Files,將值設定為No。

或者:

選中該png檔案,在FileInspector面板中,找到File Type,將其由 "PNG" 修改為 "Icon".

27、警告: noprevious prototype for function

開啟Target->BuildSettings,搜尋prototype,將Missing Function ProtoTypes改為NO。

28、CorePlot編譯時間出現 錯誤“Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clangfailed with exit code 1”

請將Scheme 從 iOS Device 改為 iPhone 5.0 Simulator。或者將Compiler for C/C++ 改為 LLVM GCC4.2。同時,Core Plot 1.0 不再支援老的 armv6 CPU。

29、使用CABasicAnimation改變UIView的alpha值無效

UIView的alpha值,在CALayer中其實是"opacity",請使用opcity作為keyPath。

30、CorePlost:定製 Axis Label 後,Tick Mark 不顯示。

設定Axis 的majorTickLocations 為你想顯示 tick mark 的位置。

NSMutableArray*customTickLocations=[[[NSMutableArray alloc]init]autorelease];

for(int i=0;i<10;i++){

[customTickLocationsaddObject:[NSNumber numberWithInt:i]];

}

xAxis.majorTickLocations=[NSSetsetWithArray:customTickLocations];

31、定製的UITableViewCell, indentationLevel不能生效

需要在定製的UITableViewCell中實現layoutSubviews方法。

- (void)layoutSubviews

{

[super layoutSubviews];

float indentPoints = self.indentationLevel *self.indentationWidth;

for(UIView *view in self.subviews){

view.frame = CGRectMake(

view.frame.origin.x+indentPoints,

view.frame.origin.y,

view.frame.size.width,

view.frame.size.height

);

}

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.