tags:

views:

85

answers:

2

Hi , 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......

A: 

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.

William Jockusch
Yes, I want to show animating the auto scrolling tableview . WHere can i use scrollToRowAtIndexPath fuction in my code.
dragon
A: 

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]

TopChul
Can you post some code about smooth scrolling down .
dragon
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 UIScrollViewor(scrollToRowAtIndexPath:atScrollPosition:animated:) on UITableView.Good luck.
TopChul