您好,登錄后才能下訂單哦!
Next
Previous
Troubleshooting
故障排除
If you have trouble getting the BirdWatching app to work correctly, try the problem-solving approaches described in this chapter.
如果BirdWatching app運行的時候有問題,嘗試本章中描述的解決問題的辦法。
Code and Compiler Warnings
代碼和編譯器警告
If the app isn’t working as it should, first compare your code with the code in “Code Listings.”
如果app沒有如它應該的那樣運行,首先將你的代碼和代碼清單中的代碼進行比較。
The tutorial code should compile without any warnings. If Xcode reports a warning, it’s a good idea to treat the warning in the same way that you treat errors. Objective-C is a very flexible language, and sometimes a warning is the only indication you receive when there is an issue that might cause an error.
本教程的代碼應該沒有任何編譯器警告。如果Xcode報告警告,與處理錯誤一樣的方式來處理這些警告是一個好主意。Objective-C是非常靈活的語言,有時候一個警告僅僅是一個跡象,告訴你那兒有問題它可能會導致錯誤。
Storyboard Items and Connections
故事板項和連接
When you’re accustomed to fixing all of an app’s problems in code, it’s easy to forget to check the objects in the storyboard. A great advantage of a storyboard is that, because it captures both the appearance and some of the configuration of app objects, you have less coding to do. To benefit from this advantage, it’s important to examine the storyboard, as well as the code, when an app doesn’t behave as you expect. Here are some examples.
當你已經習慣了修復代碼中的所有的app問題時,人們很容易忘記在故事板中檢查對象。故事板的一個很大的優勢是,因為它同時獲取對象的外觀以及對象的一些配置,你僅需要很少的代碼。受益于這種優勢,檢查故事板顯得非常重要,就像檢查代碼一樣,當app不能如你希望般起作用。這兒有一些例子。
A scene does not seem to receive the data you send to it in the prepareForSegue method. Check the segue’s identifier in the Attributes inspector. If you forget to give the segue the same identifier that you use in the prepareForSegue method, you can still transition to the scene during testing, but the scene won’t display the data that you send to it.
一個場景似乎沒有接收到你通過prepareForSegue方法發送給它的數據。在屬性檢查器中檢查segue的標識符。如果你忘了給segue和你在prpareForSegue方法里面使用的相同的標識符,你在測試的時候仍然能轉換到場景,但是場景不能顯示你發送的數據。
The same result occurs when you misspell a segue’s identifier in the prepareForSegue method. Xcode does not warn you when a segue is missing its identifier, or when the prepareForSegue method uses an incorrect identifier, so it’s important to check these values for yourself.
相同的結果也放生在當你在prepareForSegue方法里拼寫了錯誤的segue標識符。當segue缺失標識符的時候,或者當prepareforSegue方法使用不正確的標識符的時候,Xcode不會有警告,所以,自己檢查這些值非常重要。
None of your changes to a custom view controller class seem to affect its scene. Check the scene’s class in the Identity inspector. If the name of your custom view controller class is not displayed in the Class pop-up menu, Xcode does not apply your changes to the scene.
自定義視圖控制器類中做出的改變似乎沒有影響到到場景。在身份檢查器中檢查場景的類。如果你的自定義視圖控制器類的名師沒有顯示在Class彈出菜單里面,Xcode沒有應用你的改變到這個場景。
Nothing happens when you click the Cancel or Done buttons in the add scene’s navigation bar. Make sure each button is connected to its unwind action. Control-click the button on the canvas or in the document outline and confirm that the connection in the Triggered Segues section is active and correct.
當你點擊add 場景的導航條上的Done或者Cancel按鈕的時候沒有任何動作。確保每個按鈕已經聯系到它的unwind action。在畫布中或賊文檔大綱中按住Control并點擊這個按鈕,并在Triggered Segues部分去人連接是被正確觸發的。
the text fields appear to work, but the data you enter is not displayed in the master list. Make sure the view controller’s outlets are connected to the text fields.
文本字段使工作的,但你輸入的數據沒有顯示在主列表。確保視圖控制器的outlets已經連接到文本字段。
Delegate Method Names
委托方法名字
A common mistake related to using delegates is to misspell the delegate method name. Even if you’ve set the delegate object correctly, if the delegate doesn’t use the right name in its method implementation, the correct method won’t be invoked. It’s usually best to copy and paste delegate method declarations—such as textFieldShouldReturn:—from a reliable source (such as the documentation or the declaration in a header file).
使用代理的常見錯誤是拼錯委托方法的名字。即使你正確的設置了代理對象,如果在代理沒有在方法實現中使用正確的名字,正確的方法將不被調用。通常最好的方法是從可靠的來源(例如文檔或者頭文件里的聲明)復制粘貼代理方法聲明——例如textFieldShouldReturn:。
Next
Previous
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。