I am performing the Pythagorean theorem, and every time you click the “calculate” button, it refreshes my UITextField with the answer. And yes, it is a text field, not a label. For some reason, it only refreshes once, and that is the first time I try it. I tried setting it to nil first, but that didn’t work. Here is my function called when you press the button (After some debugging, I found it only is getting called once):
-(IBAction) calculate: (id) sender
{
ansNum = (fabsf(fy * fy)) + (fabsf(fx * fx));
ansNum = sqrtf(ansNum);
[fField setText:[NSString stringWithFormat:@"%g",ansNum]];
}
So your
calculatefunction is being ran when the relevant event triggers it, but running it again yields no results? Are eitherfxorfychanging so that different results should be present?You could try put some debug statements in to try and work out what is going wrong, e.g.