簡體   English   中英

我如何在UItableview中管理沒有行的部分

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM