uitextfield - iphone propgramatically read from textfield -


i have created tables text fields inside, in contacts iphone, (inspired uicatalog example)

all working, how can programatically read values of text fields, see have tag, how can read them (because cannot use ib created programatically go inside tables)(noob here!)

thanks,

im using example hello world style type on text field of table, click on button , text typed goes label, sample populate coredata db table textfields said im preatty noob please walk me trough

so when user hit submit, text label (and coredata)

 - (ibaction) submityourname;{ lblusertypedname.text = txtusername.text; nslog(@"received");  } 

this code textfield

- (uitextfield *)textfieldnormal  { if (textfieldnormal == nil) {     cgrect frame = cgrectmake(kleftmargin, 8.0, ktextfieldwidth, ktextfieldheight);     textfieldnormal = [[uitextfield alloc] initwithframe:frame];      textfieldnormal.borderstyle = uitextborderstyleroundedrect;     textfieldnormal.textcolor = [uicolor blackcolor];     textfieldnormal.font = [uifont systemfontofsize:17.0];     textfieldnormal.placeholder = @"<enter text>";     textfieldnormal.backgroundcolor = [uicolor whitecolor];     textfieldnormal.autocorrectiontype = uitextautocorrectiontypeno;    // no auto correction support      textfieldnormal.keyboardtype = uikeyboardtypedefault;   // use default type input method (entire keyboard)     textfieldnormal.returnkeytype = uireturnkeydone;      textfieldnormal.clearbuttonmode = uitextfieldviewmodewhileediting;  // has clear 'x' button right      textfieldnormal.tag = kviewtag;     // tag control can remove later recycled cells      textfieldnormal.delegate = self;    // let delegate know when keyboard's "done" button pressed      // add accessibility label describes text field for.     [textfieldnormal setaccessibilitylabel:nslocalizedstring(@"normaltextfield", @"")];    }    return textfieldnormal;    } 

and show text field in table cell

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath     { uitableviewcell *cell = nil;      static nsstring *kcelltextfield_id = @"celltextfield_id";     cell = [tableview dequeuereusablecellwithidentifier:kcelltextfield_id];     if (cell == nil)     {         // new cell needs created         cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault                                        reuseidentifier:kcelltextfield_id] autorelease];         cell.selectionstyle = uitableviewcellselectionstylenone;     }     else     {         // cell being recycled, remove old edit field (if contains 1 of our tagged edit fields)         uiview *viewtocheck = nil;         viewtocheck = [cell.contentview viewwithtag:kviewtag];         if (viewtocheck)             [viewtocheck removefromsuperview];     }      uitextfield *textfield = [[self.datasourcearray objectatindex: indexpath.section] valueforkey:kviewkey];     [cell.contentview addsubview:textfield];    return cell; } 

@mako take here here appdelegate object of application delegate class

// customize appearance of table view cells.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      static nsstring *cellidentifier = @"cell";      uitableviewcell *cell = [self.fieldtable dequeuereusablecellwithidentifier:cellidentifier];           if (cell == nil) {  cell = [self reusetableviewcellwithidentifier:cellidentifier withindexpath:indexpath];              }      // configure cell.          uitextfield *txttemp = (uitextfield *)[cell.contentview viewwithtag:1];     uitextfield *txttemp1 = (uitextfield *)[cell.contentview viewwithtag:2];     uitextfield *txttemp2 = (uitextfield *)[cell.contentview viewwithtag:3];     uitextfield *txttemp3 = (uitextfield *)[cell.contentview viewwithtag:4];                    switch (indexpath.section) {                 case 0:                         switch (indexpath.row) {                             case 0:                                  txttemp1.placeholder = @"h/no";                                 appdelegate.houseno = [nsstring stringwithformat:@"%@",txttemp1.text];                                 nslog(@"%@",appdelegate.houseno);                                 break;                                 case 1:                                 txttemp1.placeholder = @"street";                                 appdelegate.street = [nsstring stringwithformat:@"%@",txttemp1.text];                                 nslog(@"%@", appdelegate.street);                                 break;                                 case 2:                                 txttemp.placeholder = @"city";                                 txttemp2.placeholder = @"state";                                 txttemp3.placeholder = @"zip code";                                 appdelegate.city = [nsstring stringwithformat:@"%@",txttemp.text];                                 nslog(@"%@",appdelegate.city);                                 appdelegate.state = [nsstring stringwithformat:@"%@",txttemp2.text];                                 nslog(@"%@",appdelegate.state);                                 appdelegate.zipcode = [nsstring stringwithformat:@"%@",txttemp3.text];                                 nslog(@"%@",appdelegate.zipcode);                                 break;                                 default:                                 break;                                   }                                 break;       -(uitableviewcell *)reusetableviewcellwithidentifier:(nsstring *)identifier withindexpath:(nsindexpath *)indexpath {           cgrect cellrectangle = cgrectmake (0, 10, 300, 70);          cgrect field1frame = cgrectmake (10, 10, 290, 70);         cgrect field2frame = cgrectmake (10, 10, 90, 70);         cgrect field3frame = cgrectmake (110, 10, 95, 70);         cgrect field4frame = cgrectmake (220, 10, 85, 70);         uitableviewcell *cell = [[[uitableviewcell alloc] initwithframe:cellrectangle reuseidentifier:identifier] autorelease];         uitextfield *textfield;         uitextfield *textfield1;         uitextfield *textfield2;         uitextfield *textfield3;          //initialize label tag 1.          textfield = [[uitextfield alloc] initwithframe:field2frame];         textfield.tag = 1;         [cell.contentview addsubview:textfield];            //initialize label tag 2.          textfield1 = [[uitextfield alloc] initwithframe:field1frame];         textfield1.tag = 2;         [cell.contentview addsubview:textfield1];          //initialize label tag 3.          textfield2 = [[uitextfield alloc] initwithframe:field3frame];         textfield2.tag = 3;         [cell.contentview addsubview:textfield2];           //initialize label tag 4.          textfield3 = [[uitextfield alloc] initwithframe:field4frame];         textfield3.keyboardtype = uikeyboardtypenumberpad;         textfield3.tag = 4;         [cell.contentview addsubview:textfield3];             [textfield release];         [textfield1 release];         [textfield2 release];         [textfield3 release];         return cell;     } 

hope understand...good luck!


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -