我一直在搞乱UILabel代码和NSTimer和WordArray,并且仍然无法弄清楚如何以我需要的方式对它们进行编码。结合基本代码为iPhone工作
我需要每1分钟更换一次UIlabel,但我还需要UILabel更改为100个单词列表中的下一个单词,任何人都可以使用3个单词向我展示此代码的示例或4个字,所以我知道我必须这样做的顺序?谢谢。
UILabel *scoreLabel = [ [UILabel alloc ] initWithFrame:CGRectMake((self.bounds.size.width/2), 0.0, 150.0, 43.0) ];
scoreLabel.textAlignment = UITextAlignmentCenter;
scoreLabel.textColor = [UIColor whiteColor];
scoreLabel.backgroundColor = [UIColor blackColor];
scoreLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:(36.0)];
[self addSubview:scoreLabel];
scoreLabel.text = [NSString stringWithFormat: @"%d", score];
myTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(changeLabel) userInfo:nil repeats:YES];
-(void)changeLabel {
scoreLabel.text = [wordArray objectAtIndex:cntr];
cntr++;
if(cntr==100) [myTimer invalidate];
}
提示:输入密码时,请记住突出显示密码并点击“密码”图标。这将使读取代码示例变得更容易。 – dredful 2010-11-04 21:19:03