ios - Created UItextfield programmatically, how to get text later? -
i've created uitextfield programmatically when view loaded. if button pressed after loads, though, how text uitextfield in later void?
-(void)viewdidload { uitextfield *fldcard= [[uitextfield alloc] initwithframe:cgrectmake(12, 45, 293, 25)]; fldcard.placeholder = @"card"; fldcard.keyboardtype = uikeyboardtypenumberpad; [fldcard setbackgroundcolor:[uicolor colorwithred:0.22 green:0.53 blue:0.23 alpha:1.0]]; [fldcard.layer setcornerradius:5.0f]; [fldcard.layer setmaskstobounds:yes]; [self.view addsubview:fldcard]; [fldcard release]; } -(void)myaction:(id)sender { [self.view endediting:yes]; nslog(@"fldcard %@", fldcard.text); }
in .m file under:
@interface yourviewcontroller () { uitextfield *fldcard; } @end
then take out uitextfield when init fldcard. able uitextfield method in class.
Comments
Post a Comment