0

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)
        [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;
 }

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

Can anyone help me ?

Thanks in advance......

2 Answers 2

0

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]

1
  • sorry, I got a heavy work so I couldn't make some code. But, I explain this... Use NSTimer with interval some interval. At time event(selector) U could scroll your view with (scrollRectToVisible:animated:) on UIScrollView or (scrollToRowAtIndexPath:atScrollPosition:animated:) on UITableView. Good luck.
    – TopChul
    Jul 27, 2010 at 5:09
0

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.

1
  • Yes, I want to show animating the auto scrolling tableview . WHere can i use scrollToRowAtIndexPath fuction in my code.
    – dragon
    Jul 26, 2010 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.