这个问题几乎是自我解释的。我需要将UILabel实例的text属性设置为int。我该怎么做呢?对不起,如果这是一个不起眼的问题。
谢谢!
答案 0 :(得分:14)
假设你有:
UILabel *myLabel; //instance of your label
int myInt; //the integer you need to set as text into UILabel
你可以这样做,而且非常简单:
[myLabel setText:[NSString stringWithFormat:@"%d", myInt]];
或:
myLabel.text = [NSString stringWithFormat:@"%d", myInt];
答案 1 :(得分:3)
NSNumber *number = [NSNumber numberWithInt:yourInt];
[yourLabel setText:[number stringValue]];
答案 2 :(得分:2)
label.text = [NSString stringWithFormat:@"%i",intNumber];
答案 3 :(得分:0)
试试这个:
[label setText:[NSString stringWithFormat:@"%d", intValue]];