ios - UITableView DataSource method called twice -


my topic name might seems familiar , is.but believe me i've tried other answers on stack overflow still can not understand, why datasource method loads twice while i'm initialising tableview once.

(xcode6.3)

see code...

#pragma mark- uitableview - #pragma mark setup tableview -(void)setuptableview{     if(!tblevent){         cgrect frame=cgrectmake(self.view.frame.origin.x,self.view.frame.origin.y+55+50,self.view.frame.size.width,self.view.frame.size.height-(55+100));         tblevent = [self createtableviewwith_frame:frame tag:1 separatorcolor:[uicolor blackcolor] backgroundcolor:[uicolor clearcolor] scrollindicators:false];         tblevent.delegate=self;         tblevent.datasource=self;         [self.view addsubview:tblevent];     }else{         [tblevent reloaddata];     } } #pragma mark create -(uitableview*)createtableviewwith_frame:(cgrect)frame tag:(nsuinteger)tag                           separatorcolor:(uicolor*)separatorcolor                          backgroundcolor:(uicolor*)bgcolor scrollindicators:(bool)value {     uitableview *tableview = [[uitableview alloc]initwithframe:frame style:uitableviewstyleplain];     tableview.tag=tag;     tableview.backgroundcolor=bgcolor;     tableview.separatorcolor= separatorcolor;     tableview.showsverticalscrollindicator = value;     tableview.showshorizontalscrollindicator= value;      tableview.scrollenabled = yes;     tableview.separatorinset=uiedgeinsetsmake(0, 8, 0, 8);     tableview.userinteractionenabled = yes;     tableview.bounces = yes;      [tableview registerclass:[uitableviewcell class] forcellreuseidentifier:cellidentifire];      return tableview; } 

#pragma mark uitableview datasources - (nsinteger)numberofsectionsintableview:(uitableview *)tableview{ //this method called 3 times, don't know why.? :(     return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{     return totalevents.count;//this source. } - (uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{     uitableviewcell* acell = [tableview dequeuereusablecellwithidentifier:cellidentifire forindexpath:indexpath];     if(!acell){         acell=[[uitableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifire];     }      return acell; } 

#pragma mark uitableview delegates - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{     return 127.0f; } - (uiview*)tableview:(uitableview *)tableview viewforfooterinsection:(nsinteger)section{     uiview* view = [[uiview alloc]init];     return view; } 

don't use didselectrow:atindexpath: because don't need row selection.

note:-

use setuptableview method in successful response of web service , web service called viewdidload. please guide me.

is there in view controller triggering layout event (like change table header view or such)? cause call datasource methods more one.

p.s. won't allow me post comment question...


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -