iphone - UITableView delegate methods not called for uiSplitView's master view -
i have view button. when press button, uisplitview should show. problem tableview (splitview's left=master view). detail view (right) displayed correctly. left 1 empty because cellforrowatindexpath not called. .h file extends uisplitviewcontroller, , in .m file's viewdidload this:
left *l = [[left alloc] initwithnibname:@"left" bundle:nil]; right *d = [[right alloc] initwithnibname:@"right" bundle:nil]; // update split view controller's view controllers array. nsarray *viewcontrollers = [[nsarray alloc] initwithobjects:l, d, nil]; self.viewcontrollers = viewcontrollers; [viewcontrollers release];
my left.h:
@interface left : uiviewcontroller <uitableviewdatasource, uitableviewdelegate> { nsmutablearray *tabledata; uitableview *table; } @property (nonatomic, retain) nsmutablearray *tabledata; @property (nonatomic, retain) iboutlet uitableview *table;
my left.m:
#import "left.h" @implementation left @synthesize tabledata,table; - (id)initwithstyle:(uitableviewstyle)style { self = [super initwithstyle:style]; if (self) { // custom initialization } return self; } - (void)dealloc { [super dealloc]; } - (void)didreceivememorywarning { // releases view if doesn't have superview. [super didreceivememorywarning]; // release cached data, images, etc aren't in use. } #pragma mark - view lifecycle - (void)viewdidload { [super viewdidload]; table = [[uitableview alloc] initwithframe:[[uiscreen mainscreen] applicationframe] style:uitableviewstyleplain]; table.delegate = self; table.datasource = self; table.autoresizessubviews = yes; tabledata=[[nsmutablearray alloc] initwithobjects:@"bazinga",@"buzz", nil]; //nslog(@"velikost : %d", [tabledata count]); [self.view addsubview:table]; } - (void)viewdidunload { [super viewdidunload]; // release retained subviews of main view. // e.g. self.myoutlet = nil; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { // return number of sections. return 0; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // return number of rows in section. nslog(@"size: %d", [tabledata count]); return [tabledata 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] autorelease]; } // configure cell... cell.textlabel.text=[tabledata objectatindex:indexpath.row]; return cell; } } @end
how can fill master view's table data?
u have
replace this
table = [[uitableview alloc] initwithframe:[[uiscreen mainscreen] applicationframe] style:uitableviewstyleplain];
to
self.table = [[uitableview alloc] initwithframe:[[uiscreen mainscreen] applicationframe] style:uitableviewstyleplain];
becuase have used call self u have synthesized table.
so have this
Comments
Post a Comment