Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 自动滚动UITableView问题_Iphone - Fatal编程技术网

Iphone 自动滚动UITableView问题

Iphone 自动滚动UITableView问题,iphone,Iphone,我使用下面的代码自动滚动UITableview - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [DataArray count]; } - (CGFloat)tabl

我使用下面的代码自动滚动UITableview

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


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

- (CGFloat)tableView:(UITableView *)tableView  heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
    return 60;
}


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

     static NSString *identifier = @"CustomTableCell";
    CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) 
    {
        cell = [[[CustomTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
    }

    if(isAutoScrollEnabled)
        [DataTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];


    cell.Time.text  = [[DataArray objectAtIndex:indexPath.row]objectForKey:@"CurrentTime"];
    cell.SerialNo.text = [NSString stringWithFormat:@"%d",indexPath.row+1];

    return cell;
 }
但每次我在tableview中重新加载数据时,它都会影响我的tableview。有什么解决办法吗

有人能帮我吗


提前谢谢……

我不知道你到底在说什么。但我要说的是,在您的CellForRowatineXpath中调用ScrollToRowatineXpath看起来可能会导致问题。您所做的是告诉它在每次生成单元格时滚动。这看起来不对

我还想知道你是否真的想制作滚动动画。

你想要什么

平滑滚动到下? 或 滚动到新的单元格位置

第一种情况(平滑滚动)应使用NSTimer。
第二种情况(新单元格位置)应覆盖UITableView[updateData]

是,我想显示自动滚动tableview的动画。在我的代码中哪里可以使用ScrollToRowatineXpath函数。对不起,我的工作很繁重,所以无法编写一些代码。但是,我解释一下。。。使用带有间隔的NSTimer。在时间事件(选择器)时,您可以使用UIScrollView上的(scrollRectToVisible:动画:)或UITableView上的(ScrollToRowatineXpath:atScrollPosition:动画:)滚动视图。祝你好运