Why is this iPhone app's “quote” button not re

2019-08-09 04:08发布

问题:

I am working through the "iPhone introduction for programmers" tutorial at http://www.raywenderlich.com/21320/objectively-speaking-a-crash-course-in-objective-c-ios6, and my present project is at http://JonathansCorner.com/project/Quotes.tgz. The tutorial's focus is on providing an iPhone app that randomly displays one of several quotes in a Text View when you click on a Button. Later on the tutorial pushes further by defining properties and storing and retrieving XML, but I'm at the first "Let Her Rip!", which offers the first attempt running the app within the simulator with some increment of functionality, which should be that when you click a button, a randomly pulled quote appears. The text should be read-only as far as editing with the keyboard is concerned.

The behavior I am presently observing is that the simulator displays the Text View's native lorem ipsum. It continues to do so after clicking the button, and when you click on the Text View, it pulls up the keyboard and edits it. I've checked my wiring, and I don't see where I failed to duplicate what the tutorial shares. (The tutorial references a ViewController.[h|m]; is it a problem that I have a prefix before everything that takes a prefix when creating the project, e.g. CJSHViewController.h?) It behaves like one would expect from following the tutorial up to that point but not wiring event handling up or turning off edit mode for the Text View.

Any help or nitpicks would be welcome. (I am a programmer just beginning in iOS, so if there are "programmers new to iOS development" errors, I may have made at least one.)

Thank you,

回答1:

The function you wrote for changing the text in the text view is working perfectly. The problem is with your IBOutlets. You never linked the outlet for the text view to the text view and consequently when you assign new text to it, it has no where to go.



回答2:

Ok checked your project and found the error: The problem is that quoteText is not referenced on the storyboard file so... Go to your .storyboard file and drag the + symbol from the Connections Inspector to the view controller as shown on the screenshot when you click up a context menu should appear with the following options

quoteText view

Of course you click on quoteText

Hope this helps