I am using 4 UILabels in one view.
-(void)setQuestion{
Challenge = [[[UILabel alloc] initWithFrame:CGRectMake(16, 70, 294, 150)] autorelease];
Challenge.text = challengetext ;
Challenge.lineBreakMode = UILineBreakModeWordWrap;
Challenge.backgroundColor = [UIColor clearColor];
[self.view addSubview:Challenge];
Question = [[[UILabel alloc] initWithFrame:CGRectMake(16, 100 + Challenge.frame.size.height, 294, 150)] autorelease];
Question.text = activeQuestion ;
Question.lineBreakMode = UILineBreakModeWordWrap;
Question.backgroundColor = [UIColor clearColor];
[self.view addSubview:Question];
Answer = [[[UILabel alloc] initWithFrame:CGRectMake(16, 130 + Challenge.frame.size.height + Question.frame.size.height , 294, 150)] autorelease];
Answer.text = [theQuiz objectAtIndex:row+1] ;
Answer.lineBreakMode = UILineBreakModeWordWrap;
Answer.backgroundColor = [UIColor clearColor];
[self.view addSubview:Answer];
Description = [[[UILabel alloc] initWithFrame:CGRectMake(16, 160 + Challenge.frame.size.height + Question.frame.size.height + Answer.frame.size.height , 294, 150)] autorelease];
Description.text = [theQuiz objectAtIndex:row+2] ;
Description.lineBreakMode = UILineBreakModeWordWrap;
Description.backgroundColor = [UIColor clearColor];
[self.view addSubview:Description];
}
There is a one button for next Question.
-(IBAction)next{
[scrollview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
NSInteger endOfQuiz = [theQuiz count];
//[Challenge setHidden:YES];
if((((questionNumber - 1) * 4) + 4) == endOfQuiz)
{
restartGame = YES;
}else
{
[self setQuestion];
}
}
当我点击下一个按钮时,我从文本文件中得到了下一个问题。
但问题是每次我点击下一个标签上的文本都会重叠。
What should i do for that??
谢谢..
I am using 4 UILabels in one view.
-(void)setQuestion{
Challenge = [[[UILabel alloc] initWithFrame:CGRectMake(16, 70, 294, 150)] autorelease];
Challenge.text = challengetext ;
Challenge.lineBreakMode = UILineBreakModeWordWrap;
Challenge.backgroundColor = [UIColor clearColor];
[self.view addSubview:Challenge];
Question = [[[UILabel alloc] initWithFrame:CGRectMake(16, 100 + Challenge.frame.size.height, 294, 150)] autorelease];
Question.text = activeQuestion ;
Question.lineBreakMode = UILineBreakModeWordWrap;
Question.backgroundColor = [UIColor clearColor];
[self.view addSubview:Question];
Answer = [[[UILabel alloc] initWithFrame:CGRectMake(16, 130 + Challenge.frame.size.height + Question.frame.size.height , 294, 150)] autorelease];
Answer.text = [theQuiz objectAtIndex:row+1] ;
Answer.lineBreakMode = UILineBreakModeWordWrap;
Answer.backgroundColor = [UIColor clearColor];
[self.view addSubview:Answer];
Description = [[[UILabel alloc] initWithFrame:CGRectMake(16, 160 + Challenge.frame.size.height + Question.frame.size.height + Answer.frame.size.height , 294, 150)] autorelease];
Description.text = [theQuiz objectAtIndex:row+2] ;
Description.lineBreakMode = UILineBreakModeWordWrap;
Description.backgroundColor = [UIColor clearColor];
[self.view addSubview:Description];
}
There is a one button for next Question.
-(IBAction)next{
[scrollview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
NSInteger endOfQuiz = [theQuiz count];
//[Challenge setHidden:YES];
if((((questionNumber - 1) * 4) + 4) == endOfQuiz)
{
restartGame = YES;
}else
{
[self setQuestion];
}
}
When i tap on next button i got the next question from my text file.
But the problem is every time i tap next the text on label overlaps.
What should i do for that??
Thanks..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在执行
[self setQuestion]
之前尝试removeFromSuperview
您的标签:Try to
removeFromSuperview
your labels before doing[self setQuestion]
: