我使用' Command + delete'要从iOS-Simulator中的UITextView中删除文本,我无法再为UITextView设置任何文本。
textView.text = @"any text"; //no longer works
因为文字会被UITextView自动删除,如果我通过键盘输入,那么一切都会好的。
以下是代码,非常简单。
@interface ViewController ()
@property (nonatomic,strong) UITextView *textView;
@end
@implementation ViewController
-(void)loadView{
[super loadView];
self.textView = [[UITextView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.textView];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
button.backgroundColor = [UIColor blackColor];
[button setTitle:@"setText" forState:UIControlStateNormal];
button.center = self.view.center;
[button addTarget:self action:@selector(setText) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
- (void)setText{
self.textView.text = @"any text";
}