ios - Getting _detailItem and changing Label data before display -


i have been banging head against desk hour. need detail item passed 1 view controller next, , update view before displaying it. life of me, cannot work properly. here code using:

vc#1 (passing data from):

   -(ibaction)notowed:(id)sender{       inputviewcontroller *input = [[inputviewcontroller alloc]init];     self.tdmodal = input;     uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main_iphone" bundle:nil];     inputviewcontroller *viewcontroller = (inputviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"vdi"];     [self presentviewcontroller:viewcontroller animated:yes completion:nil];     [self.tdmodal setdetailitem:@"notowed"];       // setup need mynewvc     [self dismisssemimodalviewcontroller:self];   }  -(ibaction)owed:(id)sender{       inputviewcontroller *input = [[inputviewcontroller alloc]init];         [self.tdmodal setdetailitem:@"owed"];     self.tdmodal = input;       [input setdetailitem:@"owed"];      uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main_iphone" bundle:nil];     inputviewcontroller *viewcontroller = (inputviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"vdi"];     [self presentviewcontroller:viewcontroller animated:yes completion:nil];        // setup need mynewvc  [self dismisssemimodalviewcontroller:self];   } 

vc#2 (data to):

- (void)setdetailitem:(id)newdetailitem {     if (_detailitem != newdetailitem) {         _detailitem = newdetailitem;         nslog(@"this: %@", _detailitem);         [self configureview];           }  } - (void)viewdidload {     [ofield addtarget:self action:@selector(textfieldchanged:) forcontrolevents:uicontroleventeditingchanged];     [ifield addtarget:self action:@selector(textfieldchanged:) forcontrolevents:uicontroleventeditingchanged];       [super viewdidload];     id delegate = [[uiapplication sharedapplication] delegate];     self.managedobjectcontext = [delegate managedobjectcontext];     uiview *fixitview = [[uiview alloc] init];     fixitview.frame = cgrectmake(0, 0, 320, 20);     fixitview.backgroundcolor = [uicolor blackcolor]; //change match navigation bar     [self.view addsubview:fixitview];      // additional setup after loading view.     uidatepicker *picker = [[uidatepicker alloc] init];     picker.datepickermode = uidatepickermodedate;     duefield.inputview = picker;     [picker addtarget:self action:@selector(updatetextfield:) forcontrolevents:uicontroleventvaluechanged];   } - (void)configureview {     // update user interface detail item.      if (self.detailitem) {         if ([[_detailitem description]  isequal: @"owed"]){              ilabel.hidden = true;             olabel.hidden = true;             mlabel.text = @"owes me sum of";          }else{             ilabel.hidden = false;             olabel.hidden = false;              mlabel.text = @"the sum of";         }     } } - (ibaction)submit:(id)sender {       uidatepicker *picker = (uidatepicker*)duefield.inputview;       nsdateformatter *formatter = [[nsdateformatter alloc] init];        nsstring *editedmoney = [[nsstring alloc]init];     [formatter setdateformat:@"ddmmyyyy"];     [formatter setdatestyle:nsdateformatterfullstyle];     nsdate *dt = picker.date;     nsstring *dateasstring = [formatter stringfromdate:dt];     dateowed = yes;     id delegate = [[masterviewcontroller alloc] init];     self.managedobjectcontext = [delegate managedobjectcontext];     if ([_detailitem  isequal: @"owed"]) {     editedmoney = [nsstring stringwithformat:@"+$%@", ofield.text];      }else{        editedmoney = [nsstring stringwithformat:@"-$%@", ofield.text];      }       masterviewcontroller *topviewcontroller = [[masterviewcontroller alloc]init];     topviewcontroller.managedobjectcontext = self.managedobjectcontext;     nsstring *wow = [[nsstring alloc]init];     if(olabel.hidden == true){         wow = @"someoneowes";     }else{         wow=@"nope";     }     masterviewcontroller *master = [[masterviewcontroller alloc]init];     bool owedyes = dateowed;     [master setdata:ifield.text :editedmoney :picker.date :owedyes :wow :dateasstring];     nsmanagedobjectcontext *context = [self managedobjectcontext];       [uiview beginanimations:@"leftflip" context:nil];     [uiview setanimationduration:0.8];     [uiview setanimationcurve:uiviewanimationcurveeaseinout];     [uiview setanimationtransition:uiviewanimationtransitionflipfromleft forview:self.view.superview cache:yes];     [uiview commitanimations];         [self dismissviewcontrolleranimated:yes completion:nil];     [self.view.superview removefromsuperview];       nslog(@"teh %@", context); } 

the nslog on top of vc#2 reports proper string, if try use or compare string, doesn't seem work.

this

inputviewcontroller *input = [[inputviewcontroller alloc]init]; self.tdmodal = input; 

allocates new inputviewcontroller , stores in property

but this

 uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main_iphone" bundle:nil];     inputviewcontroller *viewcontroller = (inputviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"vdi"];     [self presentviewcontroller:viewcontroller animated:yes completion:nil]; 

allocates inputviewcontroller , displays it.

this

[self.tdmodal setdetailitem:@"notowed"]; 

set detailitem property in original view controller - 1 haven't displayed.

what want

-(ibaction)notowed:(id)sender{  uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main_iphone" bundle:nil];        self.tdmodal = (inputviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"vdi"];     [[self presentviewcontroller:self.tdmodal animated:yes completion:nil];     [self.tdmodal setdetailitem:@"notowed"];       // setup need mynewvc     [self dismisssemimodalviewcontroller:self]; } 

or, since going dismiss current vc, can stick local inputviewcontroller variable - need consistent , either use local variable or property.

also, if inputviewcontroller coming same storyboard current view controller can link them segue , trigger segue. can set detailitem in prepareforsegue


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -