2012-04-19 81 views
2

我开发一个标签栏应用程序中,我需要一个像我怎么能在UITableView的

我有,我有9行的表格视图管理无节无行(科目组的名称)它们在一个数组中。当我选择任何行时,它会打开另一个视图,然后输入AcctTitle并保存。当我点击另一个选项卡时,它会打开一个表格视图,并根据acct组显示行。

我的意思是,当我在前面的选项卡中选择xxx组并且一个一个地输入5 acct标题并将其保存时,在其他选项卡中,它应该显示xxx组作为节的标题,并将5个标题显示为该节的行。

不同的组有不同的行(两个不同的标签)。我怎样才能做到这一点?

+0

如果我没有理解好了,你的问题是如何沟通在你的表格视图中你逐一输入行的视图,在另一个标签中的视图中显示标题和你输入的行的视图? – Jpellat 2012-04-19 11:57:04

+0

y ...我怎么做到这一点? – success 2012-04-19 11:59:42

+0

我不知道这是否是最好的解决方案,但是你可以用一个单例类来解决这个问题,该单例类具有需要在tabBar视图中显示的数组信息。不要将数组保存在tableView中,而是保存在单例中。有了这个解决方案,所有的viewControllers比需要的信息都是一样的,所以显示相同的信息 – Jpellat 2012-04-19 12:06:41

回答

1

使用此两种方法

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

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

试用:

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

希望这有助于。

0

你只需要使用的区间值变化他们都在不同的不同的组使用这些方法。

- (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 
    } 
    } 
0
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
0

定义,其中u需要显示的部分的清单阵列。和在

- (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]; 

}

U可以试试上面的方法,使定义标题的冠军。