objective c - TableView Delegate Messages Not Being Called -


solved: not solution, used .xib rather trying use storyboard thing. whatever trying storyboard somehow messing tableview delegate methods being called. insight guys provided.

i have uiviewcontroller contains uitableview should populated array. unfortunately uitableview not populated array (which not empty).

my .h file:

@interface directory : uiviewcontroller <uitableviewdelegate, uitableviewdatasource, uisearchbardelegate> { nsarray *listdata; nsarray *savedlistdata; mkmapview* mapui; uisearchbar* searchbar; nsarray * originallistdata; uitableview* placelist; dirinfolisting *infoinst; nsstring *searchinit; nsstring *openinit; nsmutablearray *buildings;} @property (nonatomic, retain) nsarray *listdata; @property (nonatomic, retain) nsarray *savedlistdata; @property (nonatomic, retain) iboutlet uisearchbar* searchbar; @property (nonatomic, retain) iboutlet uitableview* placelist; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil list:    (nsarray*)array  mapview:(mkmapview*) map; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil list:(nsarray*)array  mapview:(mkmapview*) map search:(nsstring*) ss; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil list: (nsarray*)array  mapview:(mkmapview*) map open:(nsstring*) opentx; -(void)dodbload; @end 

and relevant stuff .m file:

#import "directory.h"  @interface directory ()  @end  @implementation directory @synthesize listdata, savedlistdata; @synthesize searchbar; @synthesize placelist;  -(nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 1;  }  -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     nslog(@"listdata count: %lu", (unsigned long)savedlistdata.count);         //this returns valid number of 74 items     return [self.savedlistdata count]; }  /*  * populates table list data , provides title. , not called  */ -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *tid = @"tabliddirect";     uitableviewcell *c = [tableview dequeuereusablecellwithidentifier:tid];      if(c == nil) {         c = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:tid];     }      nsinteger r = [indexpath row];     if([self.listdata objectatindex:r] != nil){         c.textlabel.text = ((dbbuilding*)[self.savedlistdata objectatindex:r]).name;         c.detailtextlabel.text = ((dbbuilding*)[self.savedlistdata objectatindex:r]).acronym;     }     c.accessorytype = uitableviewcellaccessorydisclosureindicator;     return c; }  /*  * displays entry according table selection , redirects user     directory information listing.  */ - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     nsinteger r = [indexpath row];     [tableview deselectrowatindexpath:indexpath animated:yes];      if(infoinst != nil) {         infoinst = nil;     }     infoinst = [[dirinfolisting alloc] initwithnibname:@"dirinfolisting" bundle:nil building:[self.savedlistdata objectatindex:r] map:mapui]; }  /*  * notification directory active view  */  - (void)viewdidappear:(bool)animated {     [super viewdidappear:animated];      if(openinit != nil)     {         [self openentry:openinit];         openinit = nil;     }      placelist = [[uitableview alloc] init];      placelist.datasource = self;     placelist.delegate = self;     [placelist reloaddata]; }  /*  * notification directory no longer active view  */  - (void)viewdiddisappear:(bool)animated {     [super viewdiddisappear:animated]; }  - (void)viewdidload {     nslog(@"listdata count: %lu", (unsigned long)listdata.count);         //also returns valid number of 74 objects within array     savedlistdata = [[nsarray alloc] initwitharray:listdata];         //that put array sanity          [super viewdidload];     // additional setup after loading view.     searchbar.text = searchinit;     [self performsearch:searchinit];      }  - (void)didreceivememorywarning {     [super didreceivememorywarning]; // dispose of resources can recreated. }  @end 

the -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)sectionmethod gets called, none of other uitableview delegate methods called , @ loss why happens.

also, whole chunk of code pulled 1 of apps (that works correctly) using .xibs , not use storyboards. app (the 1 i'm having problems with) uses storyboards, not familiar with. may doing wrong calling , using storyboard, not sure. if there may related can provide more information.

could guys please go on code , maybe see i've gone wrong? thanks!

in "viewdidload" method, change 1 line this:

self.savedlistdata = [[nsarray alloc] initwitharray:listdata]; 

except "listdata" needs be something. "self.listdata" might something, on first pass, not see "self.listdata" gets populated or set.

with properties, use "self." access (set , get) properties everywhere except in init methods.

the reason table not displaying because "numberofrowsinsection" method returning zero. set breakpoint , check that.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -