私は次のように読むラベルを持っています
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imageName.png"]];
UILabel *testLabel =[[UILabel alloc] initWithFrame:CGRectMake(65,50,200,50)]; // RectMake(xPos,yPos,Max Width I want, is just a container value);
NSString *test=@"I am thinking of a number between 1 and 100. What is it?";
testLabel.font = [UIFont systemFontOfSize:25];
testLabel.textAlignment = NSTextAlignmentCenter;
testLabel.text = test;
testLabel.numberOfLines = 0; //will wrap text in new line
[testLabel sizeToFit];
[self.view addSubview:testLabel];
この ViewController.m ページの最後で、ユーザーがフィールド値を送信した後にボタンを押します。
- (IBAction)guessNow:(id)sender {
self.usersGuess = self.guessNumberField.text;
NSString *guessString = self.usersGuess;
if ([guessString length] == 0) {
guessString = @"Really No Guess? Try Again.";
}
//_testLabel.text = @""; attempting to clear out label when user submits the value
NSString *guessReply = [[NSString alloc] initWithFormat:@"Good try but %@ is not the answer!", guessString];
self.testLabel.text = guessReply;
}
問題は、ユーザーがフィールドに値を入力して推測ボタンを押すと、最初のフィールド値の後ろに答えが表示されることです。スクリーンショットは次のとおりです。
返信のみが表示されるように、最初のメッセージを消去するにはどうすればよいですか?