Uczę się budować aplikacje na iPhone z XCode 4.5.2 i zauważyłem coś dziwnego. Jak widać pod adresem http://i.stack.imgur.com/purI8.jpg tekst wewnątrz jednego z przycisków nie jest wyświetlany w symulatorze iOS6. Próbowałem również przesunąć przycisk Enter w tym samym wierszu 0 i -, ale tekst we wszystkich trzech przyciskach linii zniknął. Ktoś wie, co jest przyczyną tego problemu i jak go rozwiązać? Oto kod:Symulator nie wyświetla tekstu przycisku
#import "CalculatorViewController.h"
#import "CalculatorBrain.h"
@interface CalculatorViewController()
@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;
@property (nonatomic, strong) CalculatorBrain *brain;
@end
@implementation CalculatorViewController
@synthesize display;
@synthesize userIsInTheMiddleOfEnteringANumber;
@synthesize brain = _brain;
- (CalculatorBrain *)brain
{
if (!_brain) _brain = [[CalculatorBrain alloc] init];
return _brain;
}
- (IBAction)digitPressed:(UIButton *)sender
{
NSString *digit = [sender currentTitle];
if (self.userIsInTheMiddleOfEnteringANumber) {
self.display.text = [self.display.text stringByAppendingString:digit];
} else {
self.display.text = digit;
self.userIsInTheMiddleOfEnteringANumber = YES;
}
}
- (IBAction)enterPressed
{
[self.brain pushOperand:[self.display.text doubleValue]];
self.userIsInTheMiddleOfEnteringANumber = NO;
}
- (IBAction)operationPressed:(UIButton *)sender
{
if (self.userIsInTheMiddleOfEnteringANumber) [self enterPressed];
NSString *operation = [sender currentTitle];
double result = [self.brain performOperation:operation];
self.display.text = [NSString stringWithFormat:@"%g", result];
}
@end
możemy zobaczyć kod? – Max
Tak, nie umieściłem tego, ponieważ tekst przycisku nie jest ustawiony za pomocą kodu, ale jeśli jest potrzebny, oto kod widoku. Działanie związane z przyciskiem to enterPressed. – Soel
Czy rozwiązano problem? – ichanduu