Quote:
Originally Posted by Bobarino
Could you show code for this custom keyboard. Also, you don't need to have an invisible button over the label. When creating the button just change its type to custom in attributes and work off of that (just easier to do for the future).
|
Well yes, that's what I meant by 'invisible button' just a button over the label with the custom attribute.
Here's the viewController.h:
Code:
@interface ComparatorViewController : UIViewController {
float result;
IBOutlet UILabel *priceOne;
IBOutlet UILabel *priceTwo;
IBOutlet UILabel *unitOne;
IBOutlet UILabel *unitTwo;
int currentOperation;
double currentNumber;
}
-(IBAction)buttonDigitPressed:(id)sender;
-(IBAction)priceTwoPressed:(id)sender;
@end
Then the viewController.m:
Code:
@implementation ComparatorViewController
-(IBAction)buttonDigitPressed:(id)sender {
currentNumber = currentNumber*10 + (double)[sender tag];
priceOne.text = [NSString stringWithFormat:@"%.2f",currentNumber / 100.0f];
}
The IBAction 'buttonDigitPressed' is linked to each button or number in this case for keyboard.