2011-05-11 124 views
0

我需要在我的應用程序中使用UITable View,它必須支持橫向和縱向方向。如何以編程方式創建表格視圖?

如果我從界面生成器拖到UITableView的直接那我怎麼才能控制它究竟

如果沒有,那麼建議我以編程方式做同樣的。

感謝 RIZWAN

+0

試着接受你以前anwers – Aravindhan 2011-05-11 05:33:21

回答

0
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
     return 1;//Returns the no of sections in the tableview 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
     return 5;//Returns the no of rows in the tableview 
    } 

//This method is called everytime when a row is created. 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

     static NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     if (cell == nil) { 

      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 

     } 

     // Configure the cell... 
     cell.textLabel.text [email protected]"tableview"; 

     return cell; 

    }