简体   繁体   中英

How can i manage no of the sections with no of rows in UItableview

I am developing a Tab Bar Application in which My need like

I Have a table view in which I have 9 rows (name of acct Groups) which are in one array. When I select any row it opens another view and I enter AcctTitle and save it. When I click On another tab it opens a table view and It should display rows according to acct group.

I mean that when I select xxx group in previous tab and enter 5 acct Title one by one and save it, in other tab it should display xxx group as a header of section and 5 titles as row in that section.

Different groups have different rows (two different tab). How can I do that?

Use this two methods

//For Number of section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

//For Number of Cell
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

Try out:

-(void)viewDidAppear:(BOOL)animated
{
    [tableview reloadData]
}

Hope this helps.

You just use the section value change they all are in different different group use these method.

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
   {
   if(section==0)
   {
    //what ever you want
   }
   if(section==1)
   {
   //what ever you want
    }
   }


  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
  if(section==0)
  {
  //what ever you want
    }
  if(section==1)
  {
  //what ever you want
  }
   }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

Define an array with list of sections u need to display. and in

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [urSectionlistArray count]}

and in the method

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ return [urSectionlistArray objectAtIndex:section]count];

define the no of rows based on the different sections defined.

U can define the title of the headers in the method

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

return [urSectionlistArray objectAtIndex:section];

}

U can try the above approach..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM