嘿家伙所以即时通讯不知道我在做什么错,但即时通讯尝试让键盘走开,当我按下我的应用程序上的返回键继承我的代码该.M:键盘不辞职当我点击返回键(xcode)
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
和代码在.H:
- (BOOL)textFieldShouldReturn:(UITextField*)textField;
但是当我运行应用程序,然后按回车键没有反应,我在做什么错?
我的.h:
#import <UIKit/UIKit.h>
@interface ChemicalInfoViewController: UIViewController{
IBOutlet UIScrollView *ChemicalInforScroller;
}
@property (strong, nonatomic) IBOutlet UITextField *PPMForChlTextField;
@property (strong, nonatomic) IBOutlet UITextField *GallonsForChlTextField;
@property (strong, nonatomic) IBOutlet UITextField *PPMForAlkTextField;
@property (strong, nonatomic) IBOutlet UITextField *GallonsForAlkTextField;
@property (strong, nonatomic) IBOutlet UITextField *PPMForPHTextField;
@property (strong, nonatomic) IBOutlet UITextField *GallonsForPHTextField;
- (IBAction)SumbitCDI:(UIButton *)sender;
@property (strong, nonatomic) IBOutlet UILabel *PPMLabelForChl;
@property (strong, nonatomic) IBOutlet UILabel *GallonsLabelForChl;
@property (strong, nonatomic) IBOutlet UILabel *PPMLabelForAlk;
@property (strong, nonatomic) IBOutlet UILabel *GallonsLabelForAlk;
@property (strong, nonatomic) IBOutlet UILabel *PPMLabelForPH;
@property (strong, nonatomic) IBOutlet UILabel *GallonsLabelForPH;
@property (strong, nonatomic) IBOutlet UITextField *ChlorinePoundsTextField;
@property (strong, nonatomic) IBOutlet UITextField *GallonsForAlkDecreaser;
@property (strong, nonatomic) IBOutlet UITextField *PhPoundsTextField;
@property (strong, nonatomic) IBOutlet UITextField *AlkPoundsTextField;
@property (strong, nonatomic) IBOutlet UITextField *LbsForAlkDecreaser;
@property (strong, nonatomic) IBOutlet UITextField *PPMForAlkDecreaser;
@property (strong, nonatomic) IBOutlet UITextField *LbsForPhDecreaser;
@property (strong, nonatomic) IBOutlet UITextField *PPMForPhDecreaser;
@property (strong, nonatomic) IBOutlet UITextField *GallonsForPhDecreaser;
- (IBAction) clickedBackground;
@interface ChemicalInfoViewController : UIView <UITextField>
@end
和我的.m:
#import "ChemicalInfoViewController.h"
@interface ChemicalInfoViewController()
@end
@implementation ChemicalInfoViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[ChemicalInforScroller setScrollEnabled:YES];
[ChemicalInforScroller setContentSize:CGSizeMake(320, 1000)];
self.textField.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (IBAction) clickedBackground {
[self.view endEditing:YES];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
这种方式仍然没有工作谢谢你呢,还有其他想法吗? – Jake 2014-12-02 21:04:22
@Jake我刚测试过它。它为我工作。 yourTextField是_你的文本field_;如果你有一个叫做“textField”的textField,那就用它替换它。 – Unheilig 2014-12-02 21:05:08
必须是我的配置有问题,即时通讯不知道,但我还应该检查什么? – Jake 2014-12-02 21:06:57