2012-04-19 65 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可以試試上面的方法,使定義標題的冠軍。