2011-03-21 64 views
1

我是Sirisha。我是iPhone新手。我想在表格視圖中顯示多行(例如:一個10,兩個15等)請幫助我。如何在UITableView中顯示多行

+1

1個部分返回3行我想你指的是「多列」 ... – Lukman 2011-03-21 05:27:46

回答

2

ü可以通過使用表中的節執行此第一部分包含10個第二部分包含15

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
return 2;  //one section in the table. 
} 

,然後使用此方法來添加的行數

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
     //number of rows in the section 

如果則第1 返回10 如果第2部分 返回15

+0

你可以開始使用的UITableView的示例代碼。 http://www.iphonesdkarticles.com/2009/03/uitableview-drill-down-table-view.html http://adeem.me/blog/2009/05/19/iphone-programming-tutorial-part-1 -uitableview-using-nsarray/ – Jhaliya 2011-03-21 05:40:45

+0

謝謝你,我會試試 – sirisha 2011-03-21 05:46:53

0

在視圖中,load load應該爲行數組分配一個數組 rowArray = [NSArray alloc] initWithObjects:@「A」,@「B」,@「C」,nil];

  • (NSInteger的)numberOfSectionsInTableView:(UITableView的*)的tableView {

    返回1; }

  • (NSInteger的)的tableView:(UITableView的*)的tableView numberOfRowsInSection:(NSInteger的)部分{ 返回[rowArray計數];

}

它會在表視圖