Cocoa Touch UITextView setText:方法无用
我有一个 UITextView,是在 Interface Builder 中为 iOS 应用程序创建的。我检查(并双重检查和三次检查)它是否正确连接到我的代码中的插座。我创建一个属性并合成它,当我运行 NSLog(@"%@", myTextView); 时,它返回 UITextView 的属性,而不是 null。但是,当我尝试调用 [myTextView setText:@"My Text."];
时,它不会更改视图上的任何内容。我在 Stackoverflow 和互联网上的其他地方发现很多人有类似的问题,但是那里的解决方案都没有帮助我。我在 Snow Leopard 上使用 Xcode 4.0.2。我试图在 -viewDidLoad
方法中执行此操作。什么可能导致此问题?
如果您需要有关我的代码设置的更多信息,请发表评论,我将更新这篇文章。
I have a UITextView which I create in Interface Builder for an iOS app. I checked (and double checked, and triple checked) that it is properly connected to the outlet in my code. I create a property and synthesize it, and when I run NSLog(@"%@", myTextView);
, it returns the UITextView's properties, not null. However, when I try calling [myTextView setText:@"My Text."];
, it doesn't change anything on the view. I have found many people with similar problems like this on Stackoverflow and other places on the internet, however none of the solutions there helped me. I am using Xcode 4.0.2 on Snow Leopard. I am attempting to do this in the -viewDidLoad
method. What could be causing this issue?
If you need any more information about my code setup, post a comment and I will update this post.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定整个文本视图在屏幕上可见,并且字体颜色与背景颜色不同吗?
Are you sure the whole text view is visible on screen, and that the font color is not the same as your background?
屏幕上显示的视图很可能与
myTextView
指向的视图不同。检查[myTextView superview]
并确保它在屏幕上。然后看看是否不小心被什么东西覆盖了。更改其他方面,例如backgroundColor
。另外,检查frame
并确保它不是CGRectZero
。It is very likely that the view that is displayed on the screen is not the same view as
myTextView
points to. Check[myTextView superview]
and make sure it's onscreen. Then look and see if you've accidentally covered it with something. Change other aspects like thebackgroundColor
. Also, check theframe
and make sure it's notCGRectZero
.