2012-03-14 3 views
6

질문은 거의 설명이 필요 없습니다. UILabel 인스턴스의 text 속성을 int로 설정해야합니다. 어떻게해야합니까? 멍청한 질문이라면 미안해.UILabel의 텍스트를 int로 설정 하시겠습니까?

감사합니다.

UILabel *myLabel; //instance of your label 
int myInt; //the integer you need to set as text into UILabel 

는이 작업을 수행 할 수 있고, 그것은 매우 간단합니다 : 당신을 가정

답변

12

는이

[myLabel setText:[NSString stringWithFormat:@"%d", myInt]]; 

나 :

myLabel.text = [NSString stringWithFormat:@"%d", myInt]; 
2
label.text = [NSString stringWithFormat:@"%i",intNumber]; 
3
NSNumber *number = [NSNumber numberWithInt:yourInt]; 
[yourLabel setText:[number stringValue]]; 
0

시험해보기 :

[label setText:[NSString stringWithFormat:@"%d", intValue]]; 
관련 문제