Objective c 底部滚动在表格视图中不起作用

Objective c 底部滚动在表格视图中不起作用,objective-c,ios7,uitableview,Objective C,Ios7,Uitableview,我正在看桌子。因为我正在显示一个数组。当我滚动tableview时,它不会向上移动到最后一个表格单元格的底部。我该怎么办呢 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1;} -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return tableRes

我正在看桌子。因为我正在显示一个数组。当我滚动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"]];

}

解决方案1:

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

NSString *cellIdentifier=[NSString stringWithFormat:@"CustomCell:%d",indexPath.row];
请改为使用以下内容:

NSString *cellIdentifier= @"CustomCellIdentifier";
静态变量只用于构造一次,并且每当调用“cellforrowatinedexpath”方法时,它总是避免创建内存。如果使用非静态变量,将创建大量内存,这可能导致滚动问题

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

使用前先分配字典

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

我通过更改表格视图框架解决了这个问题

假设您的屏幕大小为320x480,则由于您的表视图框架(原点y 130+高度480),表视图框架的底部超出屏幕130。或者,如果在屏幕底部有更多子视图覆盖tableview,则情况会更糟。更改表格视图框架,使表格视图的底部在屏幕底部结束。

什么是表格视图框架?tableview代码的父级也是..table.frame=CGRectMake(0,130,320,480);这是我的表视图框架您是否在使用UINAvigationConcoller?是的,我在所有页面中都在使用uinavigationcontroller确保在您的视图中设置属性self.automaticallyAdjustsScrollViewInsets下的Willapar方法。automaticallyAdjustsScrollViewInsets=是;self.navigationController.navigationBar.translucent=否;并将您的tableview框架设置为下表所示。frame=CGRectMake(0、130、320、480 navigationbarHeight statusbarHeight);