本文介绍了如何在 UILabel 中显示 NSArray 并使用计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用计时器在 UILabel 中显示数字数组,并按照数组中设置的顺序显示它们,但我只接收格式中的标题,然后是 SIGABRT !任何建议...谢谢

I'm trying to display an array of numbers in a UILabel using a timer,and show them in the order set in the array, but I only receive the Title in the format and then a SIGABRT !any suggestions...Thanks

部分代码有问题!

-(IBAction) rotate3
{
    NSString *number = [dayArray initWithArray:(NSArray *)dayArray];
    NSArray *array = [[NSArray alloc] initWithObjects: @"0", @"1", @"2", @"3", @"4", @"5" ,@"6", @"7", @"8",@"9",@"10",@"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18", @"19",nil];
    numberCount++;
    timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(rotate3 )userInfo:nil repeats:YES];
    self.dayArray = array;
    [array release];

    label.text = [[NSString alloc] initWithFormat:@"Day %@  " number];
}

推荐答案

很奇怪的字符串:[dayArray initWithArray:(NSArray *)dayArray];.试试这个:

It is very strange string : [dayArray initWithArray:(NSArray *)dayArray];. Try this:

-(IBAction) rotate3
{
    NSString *number = [self.dayArray description];
    NSArray *array = [[NSArray alloc] initWithObjects: @"0", @"1", @"2", @"3", @"4", @"5" ,@"6", @"7", @"8",@"9",@"10",@"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18", @"19",nil];
    numberCount++;
    timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(rotate3 )userInfo:nil repeats:YES];
    self.dayArray = array;
    [array release];

    label.text = [NSString stringWithFormat:@"Day %@  ", number];
}

这篇关于如何在 UILabel 中显示 NSArray 并使用计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 11:46