2011-01-23 9 views
0

나는 이것을 .hUIButton에서 UILabel로 텍스트 레이블 지정하기

IBOutlet UILabel *display; 

에서 선언했다. .m 다음과 같은 일을하고 있지만 작동하지 않는다는 것은 displat.text가 null이라는 것을 계속 말하고있다. 당황 스럽네, 도와 줘! 예, 나는 멍청한 행동입니다.

NSLog(@"operation button pressed %@ is of class %@",[[sender titleLabel] text],[[[sender titleLabel] text] class]); 
NSString *operation = [[sender titleLabel] text]; 
[display setText:operation]; 
NSLog(@"display text is of class %@ and equals %@",[display.text class], [display text]); 

또한 다음과 같이 시도 :

NSLog(@"digit button pressed %@ is of class %@",[sender currentTitle],[[sender currentTitle] class]); 
display.text = (NSString *)[[sender titleLabel] text]; 
NSLog(@"display text is of class %@ and equals %@",[display.text class], [display text]); 
+0

NSLog() 문을 여기에 뿌렸으므로 ... 실행 로그에 출력되는 내용은 무엇입니까? –

답변

0

두 가지가 확인 :

  1. 이 "디스플레이"출구가 인터페이스 빌더에 연결되어 있는지 확인합니다.
  2. 이 코드를 호출하기 전에 인터페이스가 완전히로드되어 있는지 확인하십시오.

2 번 항목과 관련하여 (어떤 방법으로)이 문제 코드가 어디에서 호출되는지 알려 주시면 조언하기가 쉽습니다. 그것은 행동인가 아니면 시작인가? 어디에?

+0

그 행동. IBActions로 계산기 버튼 (작업 및 숫자)이 있으며 IBOoutlet으로 표시됩니다. 단추에서 레이블을 읽고이를 표시하기 위해 display.text에 할당하려고합니다. – jason

+0

오케이 ... 아울렛이 연결되어 있습니까? 로그 명령문의 결과는 무엇입니까? 충분한 정보를 게시하지 않으면 귀하를 도울 수 없습니다. –

+0

알았습니다! 당신이 날 도와 줬어. 나는 UILabel 사이에 엉망이 있었고 올바르게 연결되지 않았다! 이제 작동! 감사! – jason