iphone - ECSlidingViewController push data to table view -


i trying use ecslidingviewcontroller available on github:

https://github.com/edgecase/ecslidingviewcontroller

anyway wondering how push data menu view controller sample table view controller because there no segue. navigation controller gets instantiated via storybaord see no way push data view another.

i tried delegates seems delegate not fire reason dont know. tableview stays empty. did miss?

please see code below:

//menuviewcontroller.h  #import <uikit/uikit.h> #import "ecslidingviewcontroller.h"  @protocol tabledata <nsobject>  - (void) somedata:(nsstring*)data;  @end  @interface menuviewcontroller : uiviewcontroller <uitableviewdatasource, uitabbarcontrollerdelegate>{      __unsafe_unretained id <tabledata> delegate; }  @property (nonatomic,assign) id <tabledata> delegate;  @end  //menuviewcontroller.m  #import "menuviewcontroller.h"  @interface menuviewcontroller() @property (nonatomic, strong) nsarray *menuitems; @end  @implementation menuviewcontroller @synthesize menuitems, delegate;  - (void)awakefromnib {   self.menuitems = [nsarray arraywithobjects:@"first", @"second", @"third", @"navigation", nil]; }  - (void)viewdidload {   [super viewdidload];    [self.slidingviewcontroller setanchorrightrevealamount:280.0f];   self.slidingviewcontroller.underleftwidthlayout = ecfullwidth;    }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)sectionindex {   return self.menuitems.count; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {   nsstring *cellidentifier = @"menuitemcell";   uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];   if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];   }    cell.textlabel.text = [self.menuitems objectatindex:indexpath.row];    return cell; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {   nsstring *identifier = [nsstring stringwithformat:@"%@top", [self.menuitems objectatindex:indexpath.row]];    uiviewcontroller *newtopviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:identifier];      if ([delegate respondstoselector:@selector(somedata:)]) {         [delegate somedata:@"hello world"];     }    [self.slidingviewcontroller anchortopviewoffscreento:ecright animations:nil oncomplete:^{     cgrect frame = self.slidingviewcontroller.topviewcontroller.view.frame;     self.slidingviewcontroller.topviewcontroller = newtopviewcontroller;     self.slidingviewcontroller.topviewcontroller.view.frame = frame;     [self.slidingviewcontroller resettopview];   }]; }  @end  //sampletableviewcontroller.h  #import <uikit/uikit.h> #import "ecslidingviewcontroller.h" #import "menuviewcontroller.h"  @interface sampletableviewcontroller : uitableviewcontroller <uitableviewdatasource, uitabbarcontrollerdelegate, tabledata>  - (ibaction)revealmenu:(id)sender;  @end  //sampletableviewcontroller.m  #import "sampletableviewcontroller.h"  @interface sampletableviewcontroller() @property (nonatomic, strong) nsarray *sampleitems; @end  @implementation sampletableviewcontroller @synthesize sampleitems;  - (void)awakefromnib {   //self.sampleitems = [nsarray arraywithobjects:@"one", @"two", @"three", nil]; }  - (void) somedata:(nsstring *)data{      sampleitems = [nsarray arraywithcontentsoffile:data]; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)sectionindex {   return self.sampleitems.count; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {   nsstring *cellidentifier = @"samplecell";   uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];   if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];   }    cell.textlabel.text = [self.sampleitems objectatindex:indexpath.row];    return cell; }  - (ibaction)revealmenu:(id)sender {   [self.slidingviewcontroller anchortopviewto:ecright]; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation {   return yes; }  @end 

i suggest using delegate. here example: delegate example


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -