|  
 
 
1.   首先,Controller需要实现两个  delegate ,分别是  UITableViewDelegate 和  UITableViewDataSource    2.然后 UITableView对象的 delegate要设置为 self。 
   3. 然后就可以实现这些delegate的一些方法拉。        (1)- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;    
         这个方法返回 tableview 有多少个section   [cpp] view plaincopy 
    //返回有多少个Sections       - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView        {           return 1;       }            (2)- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section; 
        这个方法返回   对应的section有多少个元素,也就是多少行。 
         [cpp] view plaincopy 
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section        {           return 10;       }            (3)- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath; 
                  这个方法返回指定的 row 的高度。 
                - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; 
                  这个方法返回指定的 section的header view 的高度。 
            & [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页  
 |