2014-04-28 90 views
0

我有一个表格视图。我正在显示一个数组。当我滚动tableview它不移动到最后一个表格单元格的底部。我该怎么做。底部滚动不能在表格视图

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

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

return tableResourceArray.count;} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

     NSString *cellIdentifier=[NSString stringWithFormat:@"CustomCell:%d",indexPath.row]; 

customcell *cell = (customcell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
if (cell == nil) { 
    cell = [[customcell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 

} 
    if(tableView==table) { 
      table.backgroundColor = [UIColor clearColor]; 
      table.separatorColor=[UIColor clearColor]; 


    NSDictionary *slug = [category objectAtIndex:indexPath.row]; 
      NSLog(@"gggg:%@",slug); 
      cell.ctitle.text = [NSString stringWithFormat:@"%@", [slug objectForKey:@"title"]]; 
      cell.ctitle.font=[UIFont fontWithName:@"Arial" size:12]; 

      cell.cdate.text = [NSString stringWithFormat:@"Date:%@", [slug objectForKey:@"date"]]; 
      cell.cdate.textColor=[UIColor colorWithRed:0.820 green:0.776 blue:0.526 alpha:1.000]; 
      cell.ccontent.text = [NSString stringWithFormat:@"%@", [slug objectForKey:@"content"]]; 

}

+0

什么是tablview框架?表格代码的父代也是如此。 – ajay

+0

table.frame = CGRectMake(0,130,320,480);这是我的表格视图框架 – gowtham

+0

你使用的是UINavigationCongroller吗? – ajay

回答

0

解决方案1:

您已经声明标识符非静态变量。这可能会导致滚动问题。

NSString *cellIdentifier=[NSString stringWithFormat:@"CustomCell:%d",indexPath.row]; 

下面而是使用:

NSString *cellIdentifier= @"CustomCellIdentifier"; 

静态变量被用来构建体仅一次,它避免存储器创建所有每当“的cellForRowAtIndexPath”方法被调用的时间。如果使用非静态变量,则会创建大量可能导致滚动问题的内存。

解决方案2: //不确定。但可能有帮助

使用前分配字典。

NSDictionary *slug = [[NSDictionary alloc] init]; 
    slug = [category objectAtIndex:indexPath.row]; 
0

我通过更改我的表视图框架解决了问题。

0

假设您的屏幕尺寸为320x480,由于您的表格视图的框架(原点y 130 +高度480),您的表格视图框架的底部部分在屏幕之外130。或者如果您在屏幕底部覆盖tableview的更多子视图,甚至更多。更改您的表格视图框架,以便表格视图的底部结束于屏幕底部。