我有这么简单的代码来设置一个占位符,但是一旦我输入一个字符串,所述占位符中的一个字符仍然存在。无论我将文本设置为什么,都会发生这种情况。
例如,如果我将文本设置为'test',当我开始输入字符串时,除测试中的t之外的所有字符都会消失。为什么那个角色会一直存在?
override func viewDidLoad() {
super.viewDidLoad()
self.postView.selectedRange = NSMakeRange(0, 0);
self.postView.delegate = self
self.postView.becomeFirstResponder()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
postView.text = "\(NSDate())"
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.view.endEditing(true)
}