これらのログは正確なアイデアを提供します
- (IBAction) question;
{
for (int i = 0; i < 5; i++)
{
NSLog(@"Iteration: %d",i);
questionLabel.text = @"Whats your name?";
NSLog(@"%@",questionLabel.text);
questionLabel.text = @"Whats your age?";
NSLog(@"%@",questionLabel.text);
questionLabel.text = @"Whats your height?";
NSLog(@"%@",questionLabel.text);
questionLabel.text = @"Whats your weight?";
NSLog(@"%@",questionLabel.text);
questionLabel.text = @"Whats your last name?";
NSLog(@"%@",questionLabel.text);
}
}
すべての質問を同じラベル ( ) に表示したい場合はquestionLabel
、以下のコードを記述してください。
- (IBAction) question;
{
for (int i = 0; i < 5; i++)
{
NSLog(@"Iteration: %d",i);
questionLabel.text = @"Whats your name?";
NSLog(@"%@",questionLabel.text);
questionLabel.text = [questionLabel.text stringByAppendingFormat:@"Whats your age?"] ;
NSLog(@"%@",questionLabel.text);
questionLabel.text = [questionLabel.text stringByAppendingFormat:@"Whats your height?"] ;
NSLog(@"%@",questionLabel.text);
questionLabel.text = [questionLabel.text stringByAppendingFormat:@"Whats your weight?"] ;
NSLog(@"%@",questionLabel.text);
questionLabel.text = [questionLabel.text stringByAppendingFormat:@"Whats your last name?"] ;
NSLog(@"%@",questionLabel.text);
}
}
すべての質問を別のラベルに表示したい場合は、別のラベルを作成しUILabel
て、以下のコードを記述してください
- (IBAction) question;
{
for (int i = 0; i < 5; i++)
{
NSLog(@"Iteration: %d",i);
questionLabel.text = @"Whats your name?";
NSLog(@"%@",questionLabel.text);
questionLabel1.text = @"Whats your age?";
NSLog(@"%@",questionLabel1.text);
questionLabel2.text = @"Whats your height?";
NSLog(@"%@",questionLabel2.text);
questionLabel3.text = @"Whats your weight?";
NSLog(@"%@",questionLabel3.text);
questionLabel4.text = @"Whats your last name?";
NSLog(@"%@",questionLabel4.text);
}
}