1
아이폰 용 계산기 앱을 만들려고합니다. 이제 모든 작업이 끝났으므로 사용자가 텍스트 입력란에 첫 번째 숫자를 입력하면 만들고 싶습니다. 그가 '+'버튼을 탭하면 테스트 필드 스위치 또는 탭을 다른 텍스트 필드에 넣으려고합니까버튼을 눌러 텍스트 입력란 1에서 입력란 2로 탭하는 방법
어떻게 할 수 있습니까? 여기에 사용자가 처음 -sum:sender
가 호출되는 입력 후 내가 제대로 코드를 이해한다면 헤더를
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
int a,b,c;
char op;
UILabel*operation,*result;
UITextField *num1,*num2;
}
@property (nonatomic)int a , b ,c;
@property (nonatomic)char po;
@property (nonatomic ,retain)IBOutlet UILabel*operation,*result;
@property (nonatomic ,retain)IBOutlet UITextField *num1,*num2;;
-(IBAction)sum:(id)sender;
-(IBAction)Calculate:(id)sender;
-(IBAction)Clear:(id)sender;
-(IBAction)hideKeyboard:(id)sender;
@end
하는 .m 파일
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize operation,result,num1,num2,a,b,c,po;
-(IBAction)sum:(id)sender{
[email protected]"+";
}
-(IBAction)hideKeyboard:(id)sender{
[num1 resignFirstResponder];
[num2 resignFirstResponder];
}
-(IBAction)Calculate:(id)sender{
//sum
a =num1.text.integerValue;
b= num2.text.integerValue;
c=num1.text.integerValue+num2.text.integerValue;
printf("%i >> %i",b,num2.text.integerValue);
[num1 resignFirstResponder];
[num2 resignFirstResponder];
result.text =[NSString stringWithFormat:@"%i + %i = %i",a,b,c];
}
-(IBAction)Clear:(id)sender{
[num1 resignFirstResponder];
[num2 resignFirstResponder];
[email protected]"";
[email protected]"";
[email protected]"";
a=0;
b=0;
c=0;
[email protected]"";
op=' ';
}