My current project looks like this:
For some odd reason, every time I run the IBaction textfieldBdoneediting instead of selecting text field C, it deselects everything and hides the keyboard. I have no clue what the problem is, but if anybody could help, I would appreciate it. (I'm a beginner at -C so please try to use little words
)
Code:
//
// ViewController.h
// PercentFinder
//
// Created by Danny Flax on 6/21/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController <UITextFieldDelegate>{
IBOutlet UIButton *Solve;
IBOutlet UITextField *A;
IBOutlet UITextField *B;
IBOutlet UITextField *C;
IBOutlet UILabel *Answer;
IBOutlet UILabel *AnswerPercent;
IBOutlet UILabel *Answer2;
}
-(IBAction)Solve:(id)sender;
- (IBAction)textFieldADoneEditing:(id)sender;
- (IBAction)textFieldBDoneEditing:(id)sender;
@end
//
// ViewController.m
// PercentFinder
//
// Created by Danny Flax on 6/21/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
#import <stdio.h>
#import "PercentFinderAppDelegate.h"
@implementation MyViewController
- (IBAction)textFieldADoneEditing:(id)sender
{
[B select:(id)sender];
}
- (IBAction)textFieldBDoneEditing:(id)sender
{
[C select:(id)sender];
}
-(IBAction)Solve:(id)sender{
NSString*as=[A text];
float a=[as intValue];
NSString*bs=[B text];
float b=[bs intValue];
NSString*cs=[C text];
float c=[cs intValue];
float d=((-1*b)+sqrt((b*b)-4*(a*c)))/(2*a);
float e=((-1*b)-sqrt((b*b)-4*(a*c)))/(2*a);
printf("%f and %f\n",d,e);
[Answer setText:[NSString stringWithFormat:@"%f and %f",d,e]];
}
@end
For some odd reason, every time I run the IBaction textfieldBdoneediting instead of selecting text field C, it deselects everything and hides the keyboard. I have no clue what the problem is, but if anybody could help, I would appreciate it. (I'm a beginner at -C so please try to use little words