开发者

Auto scrolling UITableView Problem

i am using below code for auto scrolling 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)
        [DataTab开发者_如何学Pythonle 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;
 }

But it fluctates my tableview every time i reload data in tableview. Is there any solution ?

Can anyone help me ?

Thanks in advance......


What do you want?

smooth scrolling to down? or scrolling to new cell position?

first case(smooth scrolling) should use NSTimer. second case(to new cell position) should override UITableView[updateData]


I'm not sure exactly what you are saying. But I will say that calling scrollToRowAtIndexPath in your cellForRowAtIndexPath looks like it could cause problems. What you are doing is telling it to scroll each time it generates a cell. That doesn't look right.

I also have to wonder if you really want to be animating that scrolling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜