iphone - Tableview doesn't fire cellForRowtIndexPath method -


my situation:

  • i've got datasource , delegate connect in storyboard
  • i've got uitableviewcell , identifier , in code defined, etc.
  • i've got array data uitableview, in debug data array filled in viewdidload method

so seems right till arrive cellforrowindexpath , numberofrowsinsection. doesn't go methods. when run further, debug complete, don't faults, black uitableview nothing in. strange cus array filled data , connected should be.

some needed, i'm searching days now!

if code needed help, ask me.

my code:

m.file:

#import "dagprogrammadetailviewcontroller.h"  @interface dagprogrammadetailviewcontroller () @end  @implementation dagprogrammadetailviewcontroller {     nsmutablearray *dagprogrammadetail; }  @synthesize menunaam; @synthesize tabledagprogrammadetail;  - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  - (void)viewdidload {     [super viewdidload];     self.navigationitem.title = menunaam;      nsarray *dagarray = [menunaam componentsseparatedbystring:@" "];     nsstring *plaatsstring = [dagarray objectatindex:1];     plaatsstring = [plaatsstring stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset]];      //object ophalen     nsmutablestring *urlstring = [nsmutablestring stringwithformat:@"http://zesdaagse.mobi-app.be/wcfurl/mobileservice.svc/getdagprogramma"];     nsurl *url = [nsurl urlwithstring:urlstring];     nsdata *data = [nsdata datawithcontentsofurl:url];     nserror *error;      nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error];      nsmutablearray *id = [nsmutablearray array];      for(nsdictionary *item in json)     {         [id addobject:[item objectforkey:@"id"]];     }      int plaats = [plaatsstring intvalue];     plaats -= 1;     //id van de dag ophalen     nsstring *iddagprogramma = [id objectatindex:plaats];      urlstring = [nsmutablestring stringwithformat:@"http://zesdaagse.mobi-app.be/wcfurl/mobileservice.svc/getdagprogrammawedstrijden?id="];     [urlstring appendstring:[nsstring stringwithformat:@"%@",iddagprogramma]];      url = [nsurl urlwithstring:urlstring];     data = [nsdata datawithcontentsofurl:url];     json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error];      nsmutablearray *idwedstrijddagprogramma = [nsmutablearray array];     nsmutablearray *naam = [nsmutablearray array];     nsmutablearray *uur = [nsmutablearray array];      for(nsdictionary *item in json)     {         [idwedstrijddagprogramma addobject:[item objectforkey:@"id"]];          [naam addobject:[item objectforkey:@"naam"]];         [uur addobject:[item objectforkey:@"uur"]];     }      dagprogrammadetail = [nsmutablearray arraywithobjects: nil];      for(int = 0; < json.count; ++)     {         nsmutablestring *lijn =[nsmutablestring stringwithformat:@"%@", [naam objectatindex:i]];         [lijn appendstring:[nsmutablestring stringwithformat:@"%s", "\t \t"]];         [lijn appendstring:[nsmutablestring stringwithformat:@"%@", [uur objectatindex:i]]];         [dagprogrammadetail addobject:lijn];     } }  //methode om aantal items te weten van de array - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return [dagprogrammadetail count]; } //methode om een item aan een index te koppelen en zichtbaar te maken - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *simpletableidentifier = @"menudetailcell";      uitableviewcell *cell = [self.tabledagprogrammadetail dequeuereusablecellwithidentifier:simpletableidentifier];      if (cell == nil) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier];      }     cell.textlabel.numberoflines = 1;     cell.textlabel.text = [dagprogrammadetail objectatindex:indexpath.row];      return cell; }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  @end 

i'm confused right know, know how fix it? cus in other view controllers works fine , it's same code , methods. should do?

  • calm down , recheck code again. guaranteed it'll silly mistake. may happens when frustrated.

things can :

1) nslog numberofrowsinsection. note , if it's "0" cellforrowatindexpath never going called.

2) if using uitableview inside uiview should add :

[self.view addsubview:table]; 

3) don't forget include :

@interface yourviewcontroller : uiviewcontroller<uitableviewdatasource,uitableviewdelegate> 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -