温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

your Second iOS App(5)—Troubleshooting

发布时间:2020-06-30 20:26:36 来源:网络 阅读:392 作者:三无青年 栏目:移动开发

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




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI