使用Code在UITextView内部编写代码
这简直要了我的命,但是如果我用代码而不是在界面生成器中创建它,是否有任何简单的方法可以在我的 UITextView 中包含 Objective-C 代码?
basicSoundTextView.text = @"NSString *name = [[NSString alloc] initWithFormat:@"NameOfSoundFile"];";
这给了我假设的错误,因为我在 textView 的文本的指定括号内使用了括号。我无法确切地告诉你它给出了什么错误,因为我尝试插入的代码没有任何问题......但是它告诉我它的格式不正确,我知道它不是完美地工作,但它没有'没关系,因为我只是想展示它。我不知道这么简单的事情怎么这么快就变得如此令人沮丧,所以提前非常感谢您!
this is killing me but is there any simple way to have objective-c code inside my UITextView if I'm creating it with code and not in interface builder?
basicSoundTextView.text = @"NSString *name = [[NSString alloc] initWithFormat:@"NameOfSoundFile"];";
Which gives me errors I'm assuming because I'm using parentheses within the designated parentheses for the text of my textView. I can't tell you exactly what error it gives because there is nothing wrong with the code I'm attempting to insert... however it is telling me it's improperly formatted which I know it isn't it works flawlessly but it doesn't matter because I'm just trying to display it. I don't know how something so simple became so frustrating so quickly so thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有一个双引号问题......
像这样重写,我相信它应该有效:
You have a double quotation problem ...
Rewrite like this and I believe it should work: