简体   繁体   English

如何处理CellForRowAtIndexpath方法

[英]How to Handle CellForRowAtIndexpath method

I had one table view in which I had 15 row in one section. 我有一个表视图,其中我在一个部分中有15行 so when the table view get loaded it shows only first 9 rows , I checked it with method CellForRowAtIndexpath method but I want to get all 15 rows to be get called in this method for the viewload method. 所以当表视图加载时它只显示前9行 ,我用方法CellForRowAtIndexpath方法检查它,但是我希望在这个方法中为viewload方法调用所有15行。 please help me on out. 请帮帮我。

thanks in advance.... 提前致谢....

it depends how much rows you set from 这取决于你设置的行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

if you have an array then return [arr count]; 如果你有一个数组然后返回[arr count]; as number of rows and if you want static rows then use return 15; 作为行数,如果你想要静态行,那么使用return 15; in this method 在这种方法中

You use these method or if you want all your cell on front of first time view then you should decrease the height of the cell using last method.And also check your array how much values he have. 您可以使用这些方法,或者如果您希望所有单元格都在第一次查看前面,那么您应该使用最后一个方法减小单元格的高度。还要检查数组他有多少值。

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
return 1;
}

-(NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section 
{
return [Array count];

}
-(UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
   static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil) {
    cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleSubtitle
             reuseIdentifier:CellIdentifier]
            autorelease];
 }
   cell.textLabel.text=[Array objectAtIndex:indexPath.row];


    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 20;//use this method for cell height
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM