iOS 開發百問(5)

來源:互聯網
上載者:User

標籤:為什麼   post   runtime   ima   ignore   調試   orm   ext   document   

42、 警告:Multiplebuild commands for output file

target引用了名字反覆的資源

找到當前的target,展開之後。找到CopyBundle Resources欄目。然後在裡面找到反覆名字的資源。刪除不要的那個就可以

43、簽名錯誤:Provisioningprofile can‘t be found

在Xcode中當你在更新了你得認證而再又一次編譯你的程式,真機調試一直會出現Code Sign error: Provisioning profile ‘XXXX’ can‘t be found是不是會另你非常惱火。以下說說解決方案,讓你非常好的解決問題。

 1.關閉你的項目。找到專案檔XXXX.xcodeproj,在檔案上點擊右鍵。選擇“顯示包內容”(ShowPackage Contents)。會新開啟一個Finder。註:事實上XXXX.xcodeproj就是一個目錄,這裡新開啟的一個Finder裡面的三個檔案就是該XXXX.xcodeproj目錄裡面的檔案。

2.在新開啟的Finder中找到project.pbxproj。而且開啟。在這之中找到你之前的認證的編碼資訊。我之前報的錯誤資訊是:

CodeSign error: Provisioning profile ‘37D44E7F-0339-4277-9A82-C146A944CD46‘,所以我用尋找的方式找到了全部包含37D44E7F-0339-4277-9A82-C146A944CD46的行。而且刪除。

3.儲存,又一次啟動你的項目。再編譯。

就OK了。

44、 升級至Xcode 4.6 後導致 arc4random_uniform 不可用

當項目升級至Xcode4.6後出現編譯錯誤:

Useof undeclared identifier ‘arc4random_uniform‘; did you mean ‘arc4random_stir‘?

 

似乎SDK 6.1 並不支援‘arc4random_uniform‘,換成‘arc4random‘後問題解決。

45、升級Xcode4.6後,出現編譯錯誤:Undefinedsymbols for architecture x86_64: "_OBJC_CLASS_$_NSMutableOrderedSet"

在build settings 中。設定 "Implicitly link Objective-C Runtime Support" 為NO,問題解決。

46、升級Xcode4.6後。出現警告:function‘sleep‘ is invalid in C99

#import<unistd.h> 後解決。升級Xcode4.6後,很多標頭檔預設並沒有被自己主動匯入。比方 stdlib.h 和 unistd.h。

47、編譯錯誤: autolayout on ios versions prior to 6.0

在Xcode 4.6 中編譯Target 4.0的app時出現此問題(真機調試。裝置為3GS,升級至iOS 6.1.3)。找到報錯的.xib 檔案。在Document面板中j將“UseAutolayout”(見)禁用。

48、怎樣設定buttonTitleLabel 的文字對齊?

設定contentHorizontalAlignment 屬性:

emailBtn.contentHorizontalAlignment= UIControlContentHorizontalAlignmentLeft;

或者用contentEdgeInset 調整文字邊距(0表示不正確齊):

emailBtn.contentEdgeInsets= UIEdgeInsetsMake(0, 10, 0, 0);

或者二者結合約一時候使用。

49、錯誤:errorDomain=UA_ASIHTTPRequestErrorDomain Code=8 "Failed to move file from

Theerror happens after the file is downloaded; but before the file is successfullymoved from the tmp location to the Cache location

發生錯誤在檔案下載到暫時檔案。但還未移動到documents目錄之前(能夠用iExplorer查看到暫時檔案的存在)。

使用“[requestsetShouldAttemptPersistentConnection:NO];”解決此問題。

50、編譯錯誤:“hasbeen modified since the precompiled header was built”

 

  先行編譯頭的時候檔案被改動。Clean一下再又一次編譯。

51、錯誤Could not change excutable permissions on the application

無法在iPhone上以同一個 AppID 安裝兩個不同的應用程式。通常是在Xcode 中運行 Project-->Profile命令時出現故障。由於一般真機調試時會在iPhone上裝一個debug 應用程式,運行 Project-->Profile 後又會向iPhone上再次安裝這個程式。兩個程式的 AppID自然是相同的。於是出現上述錯誤。解決的方法:先刪除iPhone上的那個程式。再運行Project-->Profile 命令。

52、Instruments錯誤:Targetfaild to run,例如以所看到的。


點擊菜單條Scheme 的左下角。選擇“Edit Scheme...”,在彈出表單左側側邊欄選中“Profile xxx.app”,將其“BuildConfiguration”從“Release”改動為 “Debug”。

53、查看指標所指向的對象

假設知道地址,能夠用GDB命令列印該地址所代表的對象。比如:

 po 0x1fba2e20

假設該指標不是一個對象,用:

p0x1fba2e20

54、Xcode 打包時 skip install的問題

總結:在自身project裡面須要將skipinstall 設定為NO, 在引入其它靜態庫檔案的project中skip install 設定為YES,否則在 Orgnizer 中無法公布你的程式。

-主App是須要部署的。所以不要將Skip Install設為YES, 僅僅須要改依賴項目。

55、錯誤: Pushinga navigation controller is not supported

SDK不同意直接在一個 NavigationController 中 push 一個 NavigationController。你能夠用這句代碼取代:

[self.navigationControllerpushViewController:nc.topViewController animated:YES];

56、為什麼當使用者點擊Tab bar 上的button,總是會顯示所選 NavigationController 的 rootViewController?

你能夠為TabBarController 指定一個delegate 屬性,並在 delegate 對象中實現 UITabBarControllerDelegate 託付:

#pragma mark TabBarController Delegate

- (BOOL)tabBarController:(UITabBarController *)tabBarControllershouldSelectViewController:(UIViewController *)viewController {

    UIViewController *tbSelectedController= tabBarController.selectedViewController;

    

    if ([tbSelectedController isEqual:viewController]) {

        return NO;

    }

    

    return YES;

}

57、使用setTitle 不能重新整理 NavigationBar 的標題文本

有時候使用ViewController的 setTitle 方法並不能重新整理 NavigationBar 的 title文本。極大的可能是你使用相似的代碼定製了 titleView:

UILabel* label = [[[UILabel alloc] init] autorelease];

label.backgroundColor=[UIColor clearColor];

label.text = self.title;

label.font = [UIFont systemFontOfSize: 20];

……

[self.navigationItem setTitleView: label];

假設這樣。你須要用相同的代碼又一次定製titleView,才幹重新整理 NavigationBar title。或者,使用預設的 TitleView 而不要去定製它。

58、 nested push animation can result in corrupted navigation bar……

假設你在代碼中連續多次(兩次以上)pushViewController。會出現以上資訊,這既不是錯誤也不少警告,僅僅是控制台輸出的資訊,但它會導致一些潛在的問題,比方NavigationController 的棧錯誤(比方使用者有時候必須連按兩次 backButton 才幹返回上級視圖)。往往還會伴隨有例如以下資訊的輸出:

Unbalancedcalls to begin/end appearance transitions <FirstViewController: 0x2a2c00>

所謂連續多次,是指至少有一次push 是不經過使用者互動而直接代碼調用的。比如,當使用者點擊一個 TableViewCell,彈出一個 ViewController。然後在這個ViewController 的 viewDidLoad 方法或 viewWillAppear 方法中用代碼 Push 還有一個 ViewController。這第二次push 並非由使用者動作而是由代碼觸發的,因此會導致上述問題。

解決的方法是,在第二次push 時,將 animated 參數設定為 NO。

59、真機能夠運行,模擬器不行

有時候出現模擬器不能調試的情況,程式一運行就退出,而且模擬器似乎“卡死”掉了。僅僅出現一個黑黑的表單。按Home鍵也沒有作用。

可是在真機上程式卻能夠運行。

這個問題的解決辦法未知。但有一個解決方案是:在還有一個project中開啟模擬器。然後在模擬器中把有問題的程式刪除就可以。

60、警告“numeration not handledin switch”

新的Apple LLVM compiler 4.0中,會對 switch 變數進行檢查。假設該變數為枚舉類型,則須要處理全部的枚舉值。你能夠加入一個 default:break;語句表示全部未列舉的枚舉值已處理。或者將編譯選項"Check switch statements"設定為NO。

也能夠用下列宏忽略switch 檢查:

#pragmaclang diagnostic push

#pragmaclang diagnostic ignored "-Wswitch"

     ...<switchstatment>...

#pragmaclang diagnostic pop


iOS 開發百問(5)

聯繫我們

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