ios - UITableView and UIView in one UIViewController -
i want develop ipad application. have uiviewcontroller contain uitableview , uiview, , in file .xib have these 2 controllers. in viewcontroller.h: have uitableview *table , uiview *viewcontent.
in viewcontroller.m: developed functions need load data table view. need pass data uitableview uiview. use didselectrowatindexpath doesn't work:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { // object activite : here no problem ipadag1activity *activite = [[objects objectforkey:[objectsindex objectatindex:indexpath.section]] objectatindex:indexpath.row]; uiview *contentview = [[uiview alloc]init ]; //now instanciate uiviewcontroller wich contain : uiview *contentview , uitableview gsaactivityviewcontroller *activity = [[gsaactivityviewcontroller alloc]init]; //in uiview add label "desc" affect value of activite.description activity.desc.text = activite.description; }
i assuming code part of gsaactivityviewcontroller class. being said, not need create new gsaactivityviewcontroller , change label on controller, because have controller initialized.
here code doing:
//this line getting ipadag1activity correctly looks like, fine ipadag1activity *activite = [[objects objectforkey:[objectsindex objectatindex:indexpath.section]] objectatindex:indexpath.row]; //this code creating brand new uiview called *contentview, never gets used. guessing getting warning unused variable here. ? line not need in program far can tell because don't need create new contentview, need use on gsaactivityviewcontroller uiview *contentview = [[uiview alloc]init ]; //the line below creating brand new instance of gsaactivityviewcontroller, don't want brand new isntance, want use gsaactivityviewcontroller has been initialized. line not need in program fas can tell. //now instanciate uiviewcontroller wich contain : uiview *contentview , uitableview gsaactivityviewcontroller *activity = [[gsaactivityviewcontroller alloc]init]; //lastly, changing text of desc on new gsaactivityviewcontroller created. controller did not need created , not being used in way other function block, when change text on desc changing text on has not been displayed , tossed out when function ends (assuming arc) //in uiview add label "desc" affect value of activite.description activity.desc.text = activite.description; so fix problem, can use self current gsaactivityviewcontroller. not need initialize new 1 (or new contentview).
so here how code should look:
ipadag1activity *activite = [[objects objectforkey:[objectsindex objectatindex:indexpath.section]] objectatindex:indexpath.row]; //in uiview add label "desc" affect value of activite.description self.desc.text = activite.description; this answer based on few assumptions, desc label property of gsaactivityviewcontroller , code resides inside gsaactivityviewcontroller.
Comments
Post a Comment