iphone - Type in two uitextfield at the same time -
i want type in 2 uitextfield @ same time.is possible?
you can using following code:
typein2.h - class 3 textfields declared. "textfieldbeingedited" textfield know textfield (text1 or text2) being edited
#import <uikit/uikit.h> @interface typein2 : uiviewcontroller <uitextfielddelegate> { uitextfield *text1; uitextfield *text2; uitextfield *textfieldbeingedited; } @property (nonatomic, retain) iboutlet uitextfield *text1; @property (nonatomic, retain) iboutlet uitextfield *text2; @end
in viewdidload method following:
- (void)viewdidload { [super viewdidload]; text1.delegate = self; text2.delegate = self; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(changebothfieldstext:) name:uitextfieldtextdidchangenotification object:nil ] ; }
textfield delegate method:
-(void)textfielddidbeginediting:(uitextfield *)textfield { if ( [textfield isequal:text1] ) { textfieldbeingedited = text1; } else textfieldbeingedited = text2; }
changebothfieldstext method:
-(void)changebothfieldstext:(nsnotification*)notification { if ( [textfieldbeingedited isequal:text1] ) { text2.text = text1.text; } else text1.text = text2.text; }
Comments
Post a Comment