문제

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{
    [self checkRun:nil];
    return YES;
}

I'm trying to complete the IBAction checkRun when the return key is pressed, by using the above code, but it doesn't seem to be working. Where am I going wrong? I thought maybe it's because I'm not directly referencing the textfield that I'm typing in, but I can't work out where I'd need to put the name of that textfield.

Thanks in advance.

도움이 되었습니까?

해결책

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;
}

다른 팁

This UITextfield subclass enables you to set a condition for the text and dynamically change the UIReturnKey: https://github.com/codeinteractiveapps/OBReturnKeyTextField

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top