gpt4 book ai didi

ios - 将多个 UILabels 重置为零

转载 作者:行者123 更新时间:2023-11-29 02:08:25 24 4
gpt4 key购买 nike

我有很多标签被标识为

int counter;
int largeCount;
int lowCount;
int cardCount;
int mButton;
int totalCount;


IBOutlet UILabel *counterLabel;
IBOutlet UILabel *largeCards;
IBOutlet UILabel *lowCards;
IBOutlet UILabel *totalCards;
IBOutlet UILabel *work;
IBOutlet UILabel *pCount;
IBOutlet UILabel *tCount;

现在我知道这有点简单,但是当 int Counter == 4 时编写此代码的最佳方法是什么,它将在代码中将所有上述标签重置为零。或者我是否将所有存储的整数和浮点值更改回 0?我已经尝试了很多 If 方法,但它似乎仍然无法正常工作。谢谢您的帮助!

最佳答案

如果我们有更多你的代码来了解你想做的事情有多复杂,那会更容易。但我想我会这样做,如果我想要“counter = 4”将所有其他存储的整数重置为 0,然后是标签。

- (void) verifyCounterAndUpdateLabels
{
switch(self.counter)
{
case 4:
self.largeCount = 0;
self.lowCount = 0;
self.cardCount = 0;
self.mButton = 0;
self.totalCount = 0;
break;
}

[self updateLabels];

}

- (void) updateLabels
{
self.counterLabel.text = [NSString stringWithFormat:@"%d", self.counter];
self.largeCards.text = [NSString stringWithFormat:@"%d", self.largeCount];
self.lowCards.text = [NSString stringWithFormat:@"%d", self.lowCount];
self.totalCards.text = [NSString stringWithFormat:@%d", self.cardCount];

// I don't know what this label should refer to
//self.work.text = [NSString stringWithFormat: @"%d", variable];
self.pCount.text = [NSString stringWithFormat: @"%d", self.mButton];
self.tCount.text = [NSString stringWithFormat: @"%d", self.totalCount];
}

关于ios - 将多个 UILabels 重置为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29543054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com