#import <UIKit/UIKit.h>
@interface XYZViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *wenben1;
@property (weak, nonatomic) IBOutlet UITextField *wenben2;
@property (weak, nonatomic) IBOutlet UITextField *wenben3;
@property (weak, nonatomic) IBOutlet UITextField *wenben4;
@property (weak, nonatomic) IBOutlet UILabel *jieguo;
@property (weak, nonatomic) IBOutlet UILabel *shuchu;
- (IBAction)kaishi:(id)sender;
- (IBAction)framee:(UIButton *)sender;
@end
#import "XYZViewController.h"
@interface XYZViewController ()
@end
@implementation XYZViewController
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField==_wenben1) {
[_wenben2 becomeFirstResponder];
}else if(textField == _wenben2)
{
[_wenben3 becomeFirstResponder];
}else if(textField==_wenben3)
{
[_wenben4 becomeFirstResponder];
}else if(_wenben4==textField)
{
[self kaishi:nil];
}
return YES;
}
- (IBAction)kaishi:(id)sender
{
//获取文本框内容
NSString *text1 = self.wenben1.text;
NSString *text2 = [self wenben2].text;
NSString *text3 = [_wenben3 text];
NSString *text4 = [_wenben4 text];
//转换
NSInteger num3 = [text3 integerValue];
NSInteger num4 = [text4 integerValue];
NSInteger num5 = num3 + num4;
_shuchu.text = [NSString stringWithFormat:@"账号是:%@\n密码是:%@",text1,text2];
//输出结果
_jieguo.text = [NSString stringWithFormat:@"%d",num5];
[self.view endEditing:YES];
}
- (IBAction)framee:(UIButton *)sender {
}
@end
运行结果: _shuchu.text = [NSString stringWithFormat:@"账号是:%@\n密码是:%@",text1,text2]; 一点作用都没有,
shuchu那个lable 没反应
而且 有时候 感觉 按钮点不动 然后把按钮放大 又点的动了 是不是黑苹果的原因啊?
|
|