简体   繁体   English

在iOS 6上更改文本视图的默认内容的正确方法是什么?

[英]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; 我在http://jonathanscorner.com/project/Quotes.tgz上 问了一个有关“跟随教程”应用程序的问题,几个人指出了松动的线在哪里。 I had not connected the IBOutlet correctly. 我没有正确连接IBOutlet。

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. 当我遇到意外的行为时,我有点玩笑地想将故事板中Text View的lorem ipsum替换为“ Hello,Australia!”。 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. 我对iPhone情节提要所做的每一个更改,方法是单击“文本视图”,然后在模拟器上用黑屏编辑并保存文本结果。 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. 如果我撤消情节提要板的编辑并恢复到原始状态,然后保存它,则该应用程序将显示原始lorem ipsum(如果单击按钮,则将其替换为引号),但这就是我要显示的全部内容开始。

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!" 我想知道最好的工程方法是使Text View最初显示“澳大利亚你好!”。 or some such string besides the "free with each install" lorem ipsum. 或“每安装一次免费” 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. 在执行此操作时,如果未隐藏标签,它将首先显示文本“ Hello,Australia”。

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! 我认为没有任何方法可以更改UIText视图的默认占位符,尽管我可能不希望看到“ lorem ipsum ...”比您更讨厌!

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. 但是,正如另一个答案所说,您也可以双击UITextView中的文本,将其替换,然后按Enter。 and it should work. 它应该工作。

So no, no way to change the default placeholder (grrrrrrrr...). 因此,不能更改默认占位符(grrrrrrrr ...)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将视图控制器添加到视图层次结构的正确方法是什么? - What's the proper way to add a view controller to the view hierarchy? 为UIView动态创建内容的正确方法是什么? - What is the Proper Way to Dynamically Create Content For a UIView? 更改UINavigationController过渡效果的正确方法是什么 - What is the proper way to change the UINavigationController transition effect 在没有将它放在当前UINavigationController的堆栈上的情况下,为新视图创建segue的正确方法是什么? - What is the proper way to create a segue to a new View without putting it on current UINavigationController's stack? 在iPhone上使用sqlite的正确方法是什么? - What's the proper way to use sqlite on the iPhone? 从视图显示新视图然后在iphone中返回新视图的正确方法是什么 - What is the proper way to display a new view from a view and then returning to it in iphone 在iOS上隐藏状态栏的正确方法,包括动画和调整根视图的大小 - Proper way to hide status bar on iOS, with animation and resizing root view 视图在iOS中显示不正确 - View is not display proper in iOS 有没有办法在iOS上以编程方式捕获/抓取文本内容? - Is there a way to capture/scrape the text content programmatically on iOS? 访问模态视图的导航按钮的正确方法是什么? - What is the proper way to access navbar buttons of a modal view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM