在' Command + delete'之后,无法为UITextView设置文本。行动?

时间:2015-05-05 03:22:38

标签: ios xcode6 ios-simulator ios8.3

我使用' 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"; 
}

0 个答案:

没有答案