ios - Is it possible to switch view to tableview from same view? -


i have viewcontroller.xib contains view, buttons,toolbarbutton, text box , tableview. when load initial screen comes without table view fine. when click on toolbarbutton say, viewtable, want view move tableview. have filled tableview data default objects this:

- (void)viewdidload {        tabledata = [[nsarray alloc] initwithobjects:@"object1",@"object2",@"object3",@"object4", nil];      [super viewdidload];  }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return [tabledata count]; }   - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = nil;      cell = [tableview dequeuereusablecellwithidentifier:@"my cell"];      if(cell==nil)     {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"my cell"];     }     cell.textlabel.text=[tabledata objectatindex:indexpath.row];     return cell; } 

so when click on toolbar view button should show tableview toolbar button has button when click on should hide table view , show initial view. possible in single xib? can achieve result if create xib , transfer control on xib wanted know if possible without creating second xib file. , navigation can use navigation controller want check , see if possible use toolbar transfer control. thanks.

first check if table view inside view, if not put inside , set delegate of datasource file owner, in view table method write code

-(void)viewtable { self.tableview.hidden = no; self.viewtoolbar.hidden=yes; } 

on button code in toolbar write

-(void)goback {    self.tableview.hidden = yes; self.viewtoolbar.hidden=no; } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -