嘿傢伙所以即時通訊不知道我在做什麼錯,但即時通訊嘗試讓鍵盤走開,當我按下我的應用程序上的返回鍵繼承我的代碼該.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