简体   繁体   中英

What is the proper way to change a Text View's default content on iOS 6?

I asked a question about the "following the tutorial" app at http://jonathanscorner.com/project/Quotes.tgz , and a couple of people pointed out where the loose wire was; I had not connected the IBOutlet correctly.

I thought, somewhat playfully, that I would replace the Text View's lorem ipsum from the storyboard with "Hello, Australia!", when I met an unexpected behavior. Every single change I made from the iPhone storyboard by clicking on the Text View and editing and saving the text results with a black screen on the simulator. If I undo the storyboard edit and restore the original state, and I save it, the app displays the original lorem ipsum (which is replaced by a quote if you click on the button), but that's all I've gotten it to display at start.

Is there some extra work involved in replacing the text initially displayed in a view? I could probably change it with duct tape by invoking a similar call to the one that pulls the quotes, but I'd like to know what is broken about my approach of "Update it from the storyboard WYSIWYG." I'd like to know what the best engineering way is to make that Text View initially display "Hello, Australia!" or some such string besides the "free with each install" lorem ipsum.

Thanks,

Is there any extra work involved in replacing the text initially displayed in a view?

The answer to this is no. All you have to do, is in Storyboard, double click on the text, and replace it with whatever you want it to be. When you do this, it will initially display the text "Hello, Australia" provided that the label is not hidden.

If I didn't answer your question, just comment with more details and I'll try to help you further.

I don't think that there is any way to change the default placeholder for the UIText view, although I probably hate seeing that "lorem ipsum..." crap more than you do!

As to why your simulator displayed a black screen is quite mysterious. There should have been no reason it would have done that (using the data you gave). I would try editing the text in the Attributes inspector and see if that gives the same results. But as the other answer says, you could also just double click on the text in the UITextView, replace it, and hit enter. and it should work.

So no, no way to change the default placeholder (grrrrrrrr...).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM