- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self checkRun:nil];
return YES;
}
我试图通过使用上面的代码在按下返回键时完成 IBAction
checkRun
,但它似乎不起作用。我哪里错了?我想可能是因为我没有直接引用我正在输入的文本字段,但我无法弄清楚我需要在哪里放置该文本字段的名称。
提前致谢。
最佳答案
ViewController.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextFieldDelegate>
@end
ViewController.m:
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UITextField *textField;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.textField.delegate = self;
}
关于ios - 按键盘上的返回键时的 Action (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22443807/