2014-04-28 27 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的更多子視圖,甚至更多。更改您的表格視圖框架,以便表格視圖的底部結束於屏幕底部。