i stucked in problem many hours , have n't found solution on so...
i have got table subview in uiviewcontroller
. when view loads, datasource methods called tableview
, receive data server , call [sometable reloaddata]
, none of data source methods called. have confirmed through breakpoints array contains 100 objects. both delegate , datasource bind file owner
in ib.
what can possibly missing ? please me... :(
outlogcontroller.h
@interface outlogcontroller : uiviewcontroller<uitableviewdatasource,uitableviewdelegate,asihttprequestdelegate> { nsmutablearray *outstandingkeys; } @property (strong, nonatomic) iboutlet uitableview *sometable; @end
outlogcontroller.m
@interface outlogcontroller () @end @implementation outlogcontroller @synthesize sometable; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. outstandingkeys = [[nsmutablearray alloc] init]; sometable = [[uitableview alloc] initwithframe:self.view.frame style:uitableviewstyleplain]; sometable.rowheight = 85; [self retrieveoutstandinglogfromserver]; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { // return number of sections. return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // return number of rows in section. return outstandingkeys.count; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if(cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } // configure cell... logunit *unit = [outstandingkeys objectatindex:indexpath.row]; cell.textlabel.text = unit.symbol; return cell; } -(cgfloat) tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return 85; } -(void) requestfinished:(asihttprequest *)request { nslog(@"%@",request.responsestring); nsarray *list = [request.responsestring jsonvalue];//contains 100 objects (int = 0; < list.count; i++) { nsarray *singletrade = [[list objectatindex:i] jsonvalue]; logunit *unit = [[logunit alloc] init]; unit.symbol = [singletrade objectatindex:0]; unit.type = [singletrade objectatindex:1]; unit.price = [singletrade objectatindex:2]; unit.remaining = [singletrade objectatindex:3]; unit.order = [singletrade objectatindex:4]; unit.time = [singletrade objectatindex:5]; [outstandingkeys addobject:unit]; } if(outstandingkeys.count > 0) { [sometable reloaddata];//does reload table } }
edit
after removing line:
sometable = [[uitableview alloc] initwithframe:self.view.frame style:uitableviewstyleplain];
datasource methods called except cellforrowatindexpath
, table disappears view since method not called. idea why can't called?
note: have confirmed have count = 100 after response server.
sometable = [[uitableview alloc] initwithframe:self.view.frame style:uitableviewstyleplain];
you have bind uitableview nib/storyboard. in case did not have alloc again tableview. removing line work
Comments
Post a Comment