如何在 UILabel 中显示 NSArray 并使用计时器

发布于 2024-12-13 23:30:00 字数 671 浏览 2 评论 0原文

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

部分代码有问题!

-(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];
} 

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

Part of the code with problems!

-(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];
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

打小就很酷 2024-12-20 23:30:00

这是一个非常奇怪的字符串:[dayArray initWithArray:(NSArray *)dayArray];。试试这个:

-(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];
}

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];
}
太傻旳人生 2024-12-20 23:30:00

您的 SIGABRT 可能是由于堆栈损坏: NSTimer 只能与以下形式的选择器一起使用:

- (void)myTimerFireMethod: (NSTimer *)timer;

但您尝试将其与

- (void)rotate3;

没有足够参数的选择器一起使用。

Your SIGABRT is probably due to stack corruption: NSTimer can only be used with selectors of the form:

- (void)myTimerFireMethod: (NSTimer *)timer;

but you're trying to use it with

- (void)rotate3;

which doesn't take enough arguments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文