[英]How can i manage no of the sections with no of rows in UItableview
我正在开发一个标签栏应用程序,其中我需要
我有一个表视图,其中有9个行(acct组的名称)在一个数组中。 当我选择任何行时,它将打开另一个视图,然后输入AcctTitle
并将其保存。 当我在另一个选项卡上单击时,它将打开一个表视图,并且应根据acct组显示行。
我的意思是,当我在上一个选项卡中选择xxx组并一个接一个地输入5 acct标题并保存时,在其他选项卡中,应该将xxx组显示为该部分的标题,将5个标题显示为该部分的行。
不同的组具有不同的行(两个不同的选项卡)。 我怎样才能做到这一点?
使用这两种方法
//For Number of section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//For Number of Cell
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
试用:
-(void)viewDidAppear:(BOOL)animated
{
[tableview reloadData]
}
希望这可以帮助。
您只需要使用节值更改它们都在不同的组中就可以使用这些方法。
- (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
用需要显示的部分列表定义一个数组。 和在
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [urSectionlistArray count]}
并在方法中
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ return [urSectionlistArray objectAtIndex:section]count];
根据定义的不同部分定义行数。
U可以在方法中定义标题的标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [urSectionlistArray objectAtIndex:section];
}
您可以尝试上述方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.