Mam to zadeklarowane w .h
IBOutlet UILabel *display;
aw .m robię co następuje, ale to nie działa, powtarzaj, że displat.text jest zerowa. Zdziwiony, pomóż! Tak, jestem noobem.
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]);
Próbowałem też tak:
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]);
Odpowiedzi:
0 dla odpowiedzi № 1Dwie rzeczy do sprawdzenia:
- Upewnij się, że gniazdo „display” jest podłączone w programie Interface Builder.
- Przed wywołaniem tego kodu upewnij się, że interfejs jest w pełni załadowany.
Jeśli chodzi o punkt 2, łatwiej jest udzielić porady, jeśli poinformujesz nas, skąd ten kod problemu jest wywoływany (z jakiej metody). Czy jest to akcja, czy podczas uruchamiania? Gdzie?