obj-c txt 关联。关系 txt输入框操作

时间:2022-04-08 11:37:53
//.h 文件


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UITextFieldDelegate> // type 选择outlet 然后在后面加上。<UITextFieldDelegate>

@property (retain, nonatomic) IBOutlet UITextField *TXF;


//.c文件 中。

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize TXF;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[TXF setDelegate:self]; //不要忘了这。
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

//可用于在TXT输入时的判断。在输入之前先判断。把回BOOL型
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSLog(@"first...\n");
return YES;
}

@end



http://www.cnblogs.com/qingjoin/archive/2012/06/28/2567248.html