0
votes

I have a function

 -(void)setCurrentDuration:(double)currentTime
 {
     [self.slider setValue:currentTime animated:YES];
 }

in a UIPhilosophyViewCell cell.

calling

for (UIPhilosophyViewCell* cell in [self.customTableView visibleCells])
    {
        if ([cell isKindOfClass:[UIPhilosophyViewCell class]])
        {
            if ([TRIM(cell.dicData[@"id"]) isEqualToString:self.currentPlayingID])
            {
                [cell.audioProgressViewController setCurrentDuration:[self.audioPlayer currentTime]];
            }
        }
    }

animates slider value change but setCurrentDuration called from selector of notification observer doesn't. Any suggestions on what could be the issue?

adding the cell to notification center

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveTestNotification:) name:@"playingProgress" object:nil];

and selector

- (void) receiveTestNotification:(NSNotification *) notification
{
    NSDictionary* data = notification.object;
    if (data == nil)
    {
        data = [NSDictionary dictionary];
    }

    if ([[notification name] isEqualToString:@"playingProgress"] && [TRIM(self.dicData[@"id"]) isEqualToString:TRIM(data[@"id"])])
    {
        [self setCurrentDuration:[(NSNumber*)TRIM(data[@"currentDuration"]) doubleValue]];
    }
    else
    {
        [self setCurrentDuration:0];
    }
}

TRIM is function to get non nil object or string

1
I would assume the issue is thread-related; i.e. ensure you make the changes on the UI thread from the observer. - trojanfoe
still no animation after wrapping [self setCurrentDuration:[(NSNumber*)TRIM(data[@"currentDuration"]) doubleValue]]; in dispatch_async(dispatch_get_main_queue(), ^() {} - Sameer Azeem

1 Answers

0
votes

TableView reload or update maybe stop the animation of cell.

So, try change to use [self.slider setValue:currentTime animated:NO];

And if the setValue work, you need consider the animation implement.